<jacob@aers.ca> writes:
> leaf_category_1
Ah. So you are wishing it would use this index:
"search_site1_2009_03_13_leaf_category_1" btree (leaf_category_1,
site_id) WHERE leaf_category_1 IS NOT NULL
If I were you I'd drop the WHERE clause, which is eliminating no index
entries whatsoever (since the column is actually declared not null).
What it is doing is forcing the planner to expend many cycles proving
that the query's WHERE clause requires leaf_category_1 to be non-null
hence the index is potentially usable. The reason recent releases
are giving you trouble is that we put a limit on how many cycles we'd
expend on such silliness.
If you really don't want to change the schema, you could work around
the issue by adding a separate "leaf_category_1 IS NOT NULL" test to
the query, so that the planner can prove the index is relevant without
having to grovel through hundreds of IN-list items to do it.
In general, this table schema looks like somebody has drastically
overengineered the index definitions with rather little understanding
of what they were doing or what the performance consequences would be.
I hope the table is read-mostly, because you're paying a *lot* anytime
you update those indexes.
regards, tom lane