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

Re: Useless sort by

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gaetano Mendola <mendola(at)gmail(dot)com>
Cc: pgsql-performance(at)postgreSQL(dot)org
Subject: Re: Useless sort by
Date: 2010-09-13 16:48:07
Message-ID: 14518.1284396487@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-performance
Gaetano Mendola <mendola(at)gmail(dot)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

In response to

Responses

pgsql-performance by date

Next:From: Gaetano MendolaDate: 2010-09-13 17:09:11
Subject: Re: Useless sort by
Previous:From: Gaetano MendolaDate: 2010-09-13 15:55:46
Subject: Re: Useless sort by

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