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 14:44:48
Message-ID: 12103.1284389088@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-performance
Gaetano Mendola <mendola(at)gmail(dot)com> writes:
> because of that sort in the view definition the first query above
> takes not less than 3 seconds. I have solved this performance issue
> removing the sort from the view definition and putting it in the
> select reducing the time from > 3secons to < 150ms.

> Can not the optimizer take rid of that useless sort on those
> kind of queries ?

It is not the optimizer's job to second-guess the user on whether a sort
is really needed there.  If we did make it throw away non-top-level
sorts, we'd have hundreds of users screaming loudly.

			regards, tom lane

In response to

Responses

pgsql-performance by date

Next:From: Tom LaneDate: 2010-09-13 15:16:40
Subject: Re: Problem with mergejoin performance
Previous:From: Tom LaneDate: 2010-09-13 14:26:28
Subject: Re: Problem with mergejoin performance

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