pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dean Gibson (DB Administrator) <postgresql@ultimeth.com>
To: pgsql-performance@postgresql.org
Subject: Re: Bypassing useless ORDER BY in a VIEW
Date: Thu, 28 Feb 2008 10:09:50 -0800
Message-ID: <47C6F8EE.1080409@ultimeth.com> (raw)
In-Reply-To: <8366.1204218820@sss.pgh.pa.us>
References: <36af4bed0802280631ja29c636w2256fb329e14b95e@mail.gmail.com>
	<8366.1204218820@sss.pgh.pa.us>

On 2008-02-28 09:13, Tom Lane wrote:
> A rule of thumb is that ORDER BY in a view is bad design, IMHO.
>
> 			regards, tom lane
>   

I was surprised to find out that apparently it's also a PostgreSQL 
extension;  standard SQL apparently disallows ORDER BY in VIEWs:

http://en.wikipedia.org/wiki/Order_by_(SQL)

When I found this out, I removed all the ORDER BYs from my VIEWs (which 
had been there for the convenience of subsequent SELECTs).

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.

-- 
Mail to my list address MUST be sent via the mailing list.
All other mail to my list address will bounce.




view thread (5+ messages)  latest in thread

Message-ID: <47C6F8EE.1080409@ultimeth.com>
Permalink:  ../47C6F8EE.1080409@ultimeth.com/
Also on:    postgresql.org/message-id/47C6F8EE.1080409@ultimeth.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: postgresql@ultimeth.com
  Subject: Re: Bypassing useless ORDER BY in a VIEW
  In-Reply-To: <47C6F8EE.1080409@ultimeth.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox