Re: [planner] Ignore "order by" in subselect if parrent do count(*) - Mailing list pgsql-performance

From Tom Lane
Subject Re: [planner] Ignore "order by" in subselect if parrent do count(*)
Date
Msg-id 17997.1330637364@sss.pgh.pa.us
Whole thread Raw
In response to Re: [planner] Ignore "order by" in subselect if parrent do count(*)  (Craig James <cjames@emolecules.com>)
List pgsql-performance
Craig James <cjames@emolecules.com> writes:
> On Thu, Mar 1, 2012 at 9:50 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Considering that ORDER BY in a subquery isn't even legal per spec,

> That's surprising ... normally it won't affect the result, but with an
> offset or limit it would.  Does the offset or limit change the "not
> even legal" part?

Well, actually, the SQL standard didn't have anything comparable to
offset/limit until SQL:2008, either.  But I have to take back my
statement above.  It wasn't legal in SQL99, but evidently they added it
in the 2003 or 2008 edition, presumably to go with the limit
functionality.

Anyway, the long and the short of it is that people depend on ORDER BY
in subqueries to be honored, and we're not going to break that.

            regards, tom lane

pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: Bad estimation for "where field not in"
Next
From: Stefan Keller
Date:
Subject: Re: PG as in-memory db? How to warm up and re-populate buffers? How to read in all tuples into memory?