crystal icon indicating copy to clipboard operation
crystal copied to clipboard

Don't recommend --no-ignore-indexes

Open benjie opened this issue 3 years ago • 2 comments

It's fundamentally broken.

benjie avatar Dec 08 '21 15:12 benjie

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.

tmcgann avatar May 10 '22 03:05 tmcgann

Issues:

  1. --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.
  2. When it comes to ordering, --no-ignore-indexes cannot know if you're going to order by organization_id and then person_id or vice versa, so in the current schema the effect of an index over (organization_id, person_id) is not clear - definitely organization_id should be included, but person_id should only be allowed if organization_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.
  3. 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.

benjie avatar May 10 '22 08:05 benjie

This is broadly fixed in V5:

  1. The ignore is uni-directional (rather than bi-directional)
  2. The ignore can be undone via the behavior system (you can explicitly tell it to be included)

benjie avatar Oct 04 '23 17:10 benjie