"Todd A. Cook" <tcook@xxxxxxxxxxxxxxxxxxxxx> writes: > Tom Lane wrote: >> Well, that's the problem right there :-(. Have you ANALYZEd this table? > My production table and query are more complex. In the original, the > query above was in a sub-select; the work-around was to create a temp > table with the sub-query results, analyze it, and then do the larger > query based off of the temp table. Hmm. One of the things that's on my TODO list is to make the planner smarter about drilling down into sub-selects to extract statistics. I think that's what's called for here, but your example has eliminated all the interesting details. Can you show us the actual query, its EXPLAIN plan, and the definitions of the tables/views involved? regards, tom lane