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

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: Bypassing useless ORDER BY in a VIEW



"Robins Tharakan" <tharakan(at)gmail(dot)com> writes:
> If I give an ORDER BY clause in a VIEW and then use it in another query
> where the VIEW's ORDER BY is immaterial, would the planner be able to
> discard this ORDER BY clause ?

No.  That's a feature not a bug; the sorts of cases where you want an
ORDER BY in a subquery, it's because you really want those rows computed
in that order (eg you've got side-effect-causing functions reading the
results).  Postgres will never discard an ORDER BY as "immaterial".

A rule of thumb is that ORDER BY in a view is bad design, IMHO.

			regards, tom lane



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2007 PostgreSQL Global Development Group