Skip site navigation (1) Skip section navigation (2)

Re: Bypassing useless ORDER BY in a VIEW

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: Bypassing useless ORDER BY in a VIEW
Date: 2008-02-28 21:52:15
Message-ID: 16851.1204235535@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-performance
"Dean Gibson (DB Administrator)" <postgresql(at)ultimeth(dot)com> writes:
> Of course, where ORDER BY in a VIEW is really helpful, is with OFFSET 
> and/or LIMIT clauses (which are also PostgreSQL extensions), which is 
> equivalent to what you point out.

Right, which is the main reason why we allow it.  I think that these
are sort of poor man's cases of things that SQL2003 covers with
"windowing functions".

The SQL spec treats ORDER BY as a cosmetic thing that you can slap onto
the final output of a SELECT.  They don't consider it useful in
subqueries (including views) because row ordering is never supposed to
be a semantically significant aspect of a set of rows.

			regards, tom lane

In response to

pgsql-performance by date

Next:From: Franck RoutierDate: 2008-02-29 11:51:34
Subject: 12 disks raid setup
Previous:From: Dean Gibson (DB Administrator)Date: 2008-02-28 18:09:50
Subject: Re: Bypassing useless ORDER BY in a VIEW

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group