Re: Multicolumn order by

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: theo(at)flame(dot)co(dot)za
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Multicolumn order by
Date: 2006-04-18 23:08:33
Message-ID: 19819.1145401713@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Theo Kramer <theo(at)flame(dot)co(dot)za> writes:
> select * from mytable where
> (c1 = 'c1v' and c2 = 'c2v' and c3 >= 'c3v') or
> (c1 = 'c1v' and c2 > 'c2v') or
> (c1 > 'c1v')
> order by c1, c2, c3;

Yeah ... what you really want is the SQL-spec row comparison operator

select ... where (c1,c2,c3) >= ('c1v','c2v','c3v') order by c1,c2,c3;

This does not work properly in any current PG release :-( but it does
work and is optimized well in CVS HEAD. See eg this thread
http://archives.postgresql.org/pgsql-hackers/2006-02/msg00209.php

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Jim C. Nasby 2006-04-18 23:13:53 Re: Multicolumn order by
Previous Message Tom Lane 2006-04-18 22:48:32 Re: creating of temporary table takes very long