Comments (5)
From by brief research I believe its common for STI libraries to behave like this.
a) I'd be curious to see numbers of the relative performance of the queries
b) we'd need this behavior to be configurable so we can support situations where there are unmapped types in the type column that shouldn't be returned by a root query.
I don't have time to dig in to the implementation details of this but a PR would always be considered.
from single-table-inheritance.
@jonspalmer Thanks for the reply.
a) When it comes to about 10000 records, it matters. I brought evidence from laravel repo.
laravel/framework#26051 (comment)
b) yes, i agree to your opinion.
I will create PR for this issue soon :)
from single-table-inheritance.
@darron1217 thanks for the details but those are not good examples of the problem.
a) The first query is only selecting one column from the table which will typically be faster than selecting "*" as there is less data to for the DB to collect and send over the wire
b) A very large "IN" query with 1000s of values in the "in' condition is potentially slow (to send as a query and to execute). However, we're talking about a max # of conditions as the max of the number of classes you have mapped.
c) The indexing performance will be very different. A type column for STI will have low cardinality (the # of mapped classes) vs a Primary Key index in those examples which will necessarily be unique. The query performance of queries against those two types of indexes will be very different. It also might be that certain SQL engines optimize the "where in" query to a no-op if you pass every value of the index 😄.
We think we need real examples of the problem at hand with sql "EXPLAIN" details of the queries.
from single-table-inheritance.
@jonspalmer
Oh, I didn't realize that I brought wrong example... haha
I'll test with index
as you mentioned :)
from single-table-inheritance.
@jonspalmer
I just tested on my database, and only 1 milisecond delayed....
Let's close this issue :)
from single-table-inheritance.
Related Issues (20)
- "Field 'type' doesn't have a default value" when saving a model HOT 3
- Update Readme HOT 1
- One record two types. HOT 3
- Can we set the type of model using the base model? HOT 5
- hasMany relation doesn't work for parent class
- Can't create a new record directly form the base class HOT 10
- Broken link in README - Mark Smith's website is gone HOT 1
- Laravel 5.7 Support HOT 6
- Type is not inserted when using Laravel factories HOT 1
- Travis Builds are failing HOT 2
- Laravel 5.8 support
- Support the Eloquent `retrieved` event HOT 1
- Cannot insert record HOT 6
- V0.8.6 causes incorrect attributes to be set HOT 11
- Laravel 6.0 support HOT 1
- Eager loading child model relationship HOT 2
- PHP hangs when parent and child inheritance is not setted properly. HOT 3
- `newFromBuilder` does not maintain mutated attributes HOT 2
- onlyTrashed()->forceDelete() seems to lose the SingleTableInheritance scope, deletes way more than intended HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from single-table-inheritance.