Re: Stable sort? - Mailing list pgsql-general

From Ron Mayer
Subject Re: Stable sort?
Date
Msg-id 45512845.9080708@cheapcomplexdevices.com
Whole thread Raw
In response to Stable sort?  ("redhog" <redhog@redhog.org>)
List pgsql-general
redhog wrote:
> Is sorting in PostgreSQL stable over subqueries, that is, is
>
> select * from (select * from A order by x) as B order by y;
>
> equivalent with
>
> select * from A order by y, x;

Seems as easy to try as to guess.

If I did this query right, it seems not.

select * from (select random()>0.5 as a, random()>0.5 as b from generate_series(1,10) order by a) as x order by b;
 a | b
---+---
 f | t
 f | f
 f | f
 f | f
 f | t
 f | f
 t | t
 t | t
 t | t
 t | f
(10 rows)

OTOH, HEY, why isn't that result ordered by 'b' instead of by 'a' (or am I misreading my query or the results)?

pgsql-general by date:

Previous
From: Wei Weng
Date:
Subject: Question on inserting and querying at the same time.
Next
From: Ron Peterson
Date:
Subject: A couple more PostgreSQL C questions