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

From Tom Lane
Subject Re: issue with double ordering in a wrapped distinct
Date
Msg-id 25752.1416354194@sss.pgh.pa.us
Whole thread Raw
In response to issue with double ordering in a wrapped distinct  (Jonathan Vanasco <postgres@2xlp.com>)
Responses Re: issue with double ordering in a wrapped distinct
List pgsql-general
Jonathan Vanasco <postgres@2xlp.com> writes:
> This is what I don't understand -- notice the two order_by calls.

>     If i run this with an inner and outer order_by, I get ~305ms.  (I don't think I need both, but I wasn't sure if
orderingis kept from a subselect ) 

>     If i run this with only the inner, I get ~304ms.

>     If I run this with only the outer, it's pushing over 10minutes again

> i'm wondering if anyone might know why that performance hit would be happening

The inner ORDER BY would prevent the planner from flattening the two
query levels into one; but as for why it gets a much worse plan after
flattening --- insufficient data.

https://wiki.postgresql.org/wiki/Slow_Query_Questions

            regards, tom lane


pgsql-general by date:

Previous
From: John Smith
Date:
Subject: how to delay sync by a set time, hour or day?
Next
From: David G Johnston
Date:
Subject: Re: issue with double ordering in a wrapped distinct