|
|
|
|
|
by takeda
2484 days ago
|
|
The column can have nulls but after a quick check there's only a single record with a null value (probably added as a test, no idea). In the bad plan a sequential scan was performed and then it removed over 4 million rows (Rows Removed by Filter: 4562849) Edit: here is the query planner's output:
https://explain.depesz.com/s/eVXI After rewriting the query (change IN into ANY(VALUES( and adding an index to the "seven" table):
https://explain.depesz.com/s/b4kU |
|
You said the index was ignored, but based on that plan output the planner made the right choice since the filter on the “sierra_zulu” table (only one there with an ANY so I assume that’s the one) matches over 90% of the rows. An index scan on that would be far worse.
Adding an index on a different table allowed the driving side of the join to be different, and, with already prefiltered data allowed the other index to be useful as well (fewer index lookups). I’d bet with that index addition your IN clause works just fine.