Re: ordering of selected rows from an ordered subselect

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Rajesh Kumar Mallah" <mallah(dot)rajesh(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: ordering of selected rows from an ordered subselect
Date: 2007-02-17 16:31:34
Message-ID: 19515.1171729894@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Rajesh Kumar Mallah" <mallah(dot)rajesh(at)gmail(dot)com> writes:
> select id , name , expensive_func(name) from
> ( select id , name from tab order by c1 desc limit 15) as foo ;
> is it guaranteed that the final result is order by c1 ?

The sub-select's output will be emitted in the specified order. What
happens after that depends on the outer query, but if you don't have any
joining or grouping then it's a reasonably safe bet that the final
output will be in the same order.

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message M.P.Dankoor 2007-02-17 17:35:09 Re: sub-limiting a query
Previous Message Andrew Sullivan 2007-02-17 15:24:34 Re: ordering of selected rows from an ordered subselect