Re: issue with double ordering in a wrapped distinct

From: Jonathan Vanasco <postgres(at)2xlp(dot)com>
To: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: issue with double ordering in a wrapped distinct
Date: 2014-11-19 01:12:10
Message-ID: FED649BB-5588-4EC2-BC23-B7E97F2DBC65@2xlp.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Yanrui Hu 2014-11-19 01:48:25 Re: About the tps explanation of pgbench, please help
Previous Message Joshua D. Drake 2014-11-19 00:23:00 Linuxfest 2015 Call for Papers