1. Indexes are not magical; their usage does not guarantee a fast query 2. It is slow because you have no non-join where condition and around 225 MILLION rows that need to be evaluated. 3. Also, you are using a correlated sub-query instead of a LEFT OUTER JOIN 4. You haven't provided table definitions with indexes and so whether q.mid=t.mid is a 1-to-1 optional relationship is unknowable. Hell, since the names are meaningless we cannot even guess what kind of relationship the tables should have. The generic "mid" field name has the same problem. David J. The weird thing is that before I updated my server the query was about 5 times faster. I've googled and I think the problem lies with the under-estimation of the query planner about
the number of rows in the nested table. I will be trying the 'set enable_seqscan = false' solution to see if that'll improve. |