Useless sort by

Поиск
Список
Период
Сортировка
Искать
От
Gaetano Mendola
Тема
Useless sort by
Дата
Msg-id
i6ks04$2jet$1@news.hub.org
Список
Дерево обсуждения
Useless sort by Gaetano Mendola <mendola@gmail.com>
Re: Useless sort by Tom Lane <tgl@sss.pgh.pa.us>
Re: Useless sort by Gaetano Mendola <mendola@gmail.com>
Re: Useless sort by Tom Lane <tgl@sss.pgh.pa.us>
Re: Useless sort by Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
Re: Useless sort by Maciek Sakrejda <msakrejda@truviso.com>
Re: Useless sort by Gaetano Mendola <mendola@gmail.com>
Re: Useless sort by Robert Haas <robertmhaas@gmail.com>
Re: Useless sort by <gnuoytr@rcn.com>
Re: Useless sort by Greg Smith <greg@2ndquadrant.com>
Re: Useless sort by Scott Marlowe <scott.marlowe@gmail.com>
Re: Useless sort by Gaetano Mendola <mendola@gmail.com>
Re: Useless sort by Robert Haas <robertmhaas@gmail.com>
Re: Useless sort by Scott Marlowe <scott.marlowe@gmail.com>
Re: Useless sort by Maciek Sakrejda <msakrejda@truviso.com>
Re: Useless sort by Dave Crooke <dcrooke@gmail.com>
Re: Useless sort by Gaetano Mendola <mendola@gmail.com>
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



В списке pgsql-performance по дате отправления
От: Gerhard Wiesinger
Дата:
От: Tom Lane
Дата:
FAQ