crystal
crystal copied to clipboard
Don't recommend --no-ignore-indexes
It's fundamentally broken.
Is this still true? Are there existing Github issues you can link?
I have this option enabled (v4.12.9) and I've run into some strange issues related to indexes lately. Sometimes indexes are ignored and the console warnings pop-up but they don't make sense. I also just ran into an issue where one of my indexes appears to recognized in some instances but not in others.
Is the reconciliation of these issues simple or complex? If there's a clear path forward, I could try to put in a PR.
Regardless, I'll be disabling since it's no longer recommended.
Issues:
-
--no-ignore-indexes
effectively leverages the@omit
smart tag system to "omit" relationships, which means it omits them in both directions. This is incorrect, it should only omit the non-indexed direction, the other direction in an FKey has to be indexed since the foreign key constraint itself references a unique index. - When it comes to ordering,
--no-ignore-indexes
cannot know if you're going to order byorganization_id
and thenperson_id
or vice versa, so in the current schema the effect of an index over(organization_id, person_id)
is not clear - definitelyorganization_id
should be included, butperson_id
should only be allowed iforganization_id
was already specified, and that's not something we can dictate schema-wise without adding a multitude of order bys (e.g.ORGANIZATION_ID_{ASC/DESC}_PERSON_ID_{ASC/DESC}
). Further, once you've ordered by those two things, adding other things on the end should be relatively safe because the sample size is small by that point, but again, that would just cause an explosion in the length of the order by. - Similar concerns for conditions, but with different expressions.
There are other issues too, like we can't understand partial indexes, or indexes that include expressions, but those are by the by.
The issues you raise sound like separate bugs, please file reproducible examples of them.
This is broadly fixed in V5:
- The ignore is uni-directional (rather than bi-directional)
- The ignore can be undone via the behavior system (you can explicitly tell it to be included)