Re: issue with double ordering in a wrapped distinct

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jonathan Vanasco <postgres(at)2xlp(dot)com>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: issue with double ordering in a wrapped distinct
Date: 2014-11-18 23:43:14
Message-ID: 25752.1416354194@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jonathan Vanasco <postgres(at)2xlp(dot)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 ordering is 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

In response to

Responses

Browse pgsql-general by date

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