pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Gaetano Mendola <mendola@gmail.com>
Cc: pgsql-performance@postgreSQL.org
Subject: Re: Useless sort by
Date: Mon, 13 Sep 2010 12:48:07 -0400
Message-ID: <14518.1284396487@sss.pgh.pa.us> (raw)
In-Reply-To: <4C8E4982.70004@gmail.com>
References: <i6ks04$2jet$1@news.hub.org>
	<12103.1284389088@sss.pgh.pa.us>
	<4C8E4982.70004@gmail.com>

Gaetano Mendola <mendola@gmail.com> writes:
> Of course I'm not suggesting to take away the "sort by" and give the user
> an unsorted result, I'm asking why the the optimizer in cases like:

>    select unique(a) from v_table_with_order_by;

> doesn't takes away the "order by" inside the view and puts it back "rewriting the
> query like this:

>    select unique(a) from v_table_without_order_by
>    order by a;

That changes the order in which the rows are fed to unique(a).  The
principal real-world use for a non-top-level ORDER BY is exactly to
determine the order in which rows are fed to a function, so we will
have a revolt on our hands if we break that.

			regards, tom lane



view thread (19+ messages)  latest in thread

Message-ID: <14518.1284396487@sss.pgh.pa.us>
Permalink:  ../14518.1284396487@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/14518.1284396487@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, mendola@gmail.com
  Subject: Re: Useless sort by
  In-Reply-To: <14518.1284396487@sss.pgh.pa.us>

* 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