From: Gaetano Mendola <mendola@gmail.com>
To: pgsql-performance@postgresql.org
Subject: Useless sort by
Date: Mon, 13 Sep 2010 11:47:24 +0200
Message-ID: <i6ks04$2jet$1@news.hub.org> (raw)
Hi all,
I have a view v_table defined as following:
select a,b,c,d,e,f
from t_table
sort by a,b,c;
the usage pattern of this view is the following:
select distinct(a) from v_table;
select distinct(b) from v_table where a = "XXX";
select distinct(c) from v_table where a = "XXX" and b = "YYYY";
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 ?
Regards
Gaetano Mendola
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: mendola@gmail.com
Subject: Re: Useless sort by
In-Reply-To: <i6ks04$2jet$1@news.hub.org>
* 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