-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5.6] Swap the index order of morph type and id #21693
Conversation
It can be utilize the index when query the type by using "WHERE type = ?", also "WHERE type IN (?)"
This is a breaking change. |
@Dylan-DPC Please point it out, I don't know it will break what. |
Your order of indexing is different so it is a tough one whether it is breaking or not |
It just speed up the sql which query by morph type. Sometimes we will query many rows with one type or some types, sql server can speed up it by this index. |
Problem here is that the new index name will be difference since the order changed, so if I have a migration with a Also won't this make it do a slower lookup by ID? Your changes will make the following queries faster:
But will make this slower
|
Search by ID only is pretty rare case for morph tables. Because it's useless to find all entities with ID of 3 without defining exact type. |
@a-komarev makes sense, only the breaking part I mentioned is a concern then. |
Temporary clone of |
Do you have to re-order the columns as well though? I know it's only a visual thing, but I've always thought having the ID before the type looked better. That wouldn't affect the performance of the index would it? |
@dwightwatson Yes, re-order the columns wouldn't affect the performance of the index. |
If it doesn't affect the performance than what are we doing? |
@taylorotwell What I'm talking about with @dwightwatson is the order of columns, not the order of indexes. |
It can be utilize the index when query the type by using "WHERE type = ?",
also "WHERE type IN (?)"