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 10:44:48 -0400
Message-ID: <12103.1284389088@sss.pgh.pa.us> (raw)
In-Reply-To: <i6ks04$2jet$1@news.hub.org>
References: <i6ks04$2jet$1@news.hub.org>

Gaetano Mendola <mendola@gmail.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



view thread (19+ messages)  latest in thread

Message-ID: <12103.1284389088@sss.pgh.pa.us>
Permalink:  ../12103.1284389088@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/12103.1284389088@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: <12103.1284389088@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