Re: issue with double ordering in a wrapped distinct - Mailing list pgsql-general

From Jonathan Vanasco
Subject Re: issue with double ordering in a wrapped distinct
Date
Msg-id FED649BB-5588-4EC2-BC23-B7E97F2DBC65@2xlp.com
Whole thread Raw
In response to Re: issue with double ordering in a wrapped distinct  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: issue with double ordering in a wrapped distinct
List pgsql-general

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.

pgsql-general by date:

Previous
From: "Joshua D. Drake"
Date:
Subject: Linuxfest 2015 Call for Papers
Next
From: Yanrui Hu
Date:
Subject: Re: About the tps explanation of pgbench, please help