On Nov 18, 2014, at 6:43 PM, Tom Lane wrote:
> but as for why it gets a much worse plan after
> flattening --- insufficient data.

Thanks.  I'll run some test cases in the morning and post the full queries 
matched with ANALYZE EXPLAIN.  
This is just puzzling to me.  I was hoping there might be a more general 
planner issue that someone would have noticed.


On Nov 18, 2014, at 6:55 PM, David G Johnston wrote:
> 
> I presume you have a reason for not simply doing away with the subquery
> altogether...

When not using the subquery, the query ran in 1s -- if I didn't have a 
LIMIT/OFFSET
Adding a LIMIT/OFFSET to that query made it run for nearly 6 minutes.
The only way I could manage to trick it to use the better query plan, was to 
wrap the "good" query as a subquery, and then run a LIMIT/OFFSET in the outer 
query.

Reply via email to