-
Notifications
You must be signed in to change notification settings - Fork 70
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
Improved polymorphic and STI index suggestions #109
Comments
Sorry for taking so long to get back to you on this topic, @plentz. I believe the order of index is as relevant as ever and will probably never be an issue of DB engine modernity. MySQL docs state:
Similarly, PSQL docs state:
This is easy to see using the Doe, John
Doe, Ziggy
Example, Fred
Example, John A query |
To be clear, I'm arguing that an index of order Both indexes fare equally well when queries have both terms like |
Hi!
I am using v2.1.8 and polymorphic indexes are still suggested despite them already being present in different order, see #107
Furthermore, I believe the suggestion should be in the format
[:poly_type, :poly_id]
. This is somewhat of a controversial topic, but the reasoning for putting the type first is that it is more useful:Pros:
Cons:
:poly_id
, but this should be a non-problem since it can be argued that searching by just polymorphic ID does not guarantee that the correct record is selected.Additionally, there are false positives when using Rails' STI pattern. If a table has a
:type
columnloldba
proposes an[:id, :type]
index, which is redundant, especially if an index on just:type
is present (and :id is indexed by default).The text was updated successfully, but these errors were encountered: