Josh Berkus <josh@agliodbs.com> writes:
> To sum up the below: it appears that whenever a set of WHERE conditions
> exceeds a certain level of complexity, the planner just ignores all
> applicable indexes and goes for a seq scan.
It looks to me like the planner is coercing the WHERE clause into
canonical OR-of-ANDs form (DNF). Which is often a good heuristic
but it seems unhelpful for this query.
> How can we fix this?
Feel free to propose improvements to the heuristics in
src/backend/optimizer/prep/prepqual.c ...
regards, tom lane