Re: Useless sort by
От
Heikki Linnakangas
Тема
Re: Useless sort by
Дата
Msg-id
4C8F1FED.3050902@enterprisedb.com
Ответ на
Re: Useless sort by (Tom Lane)
Список
Дерево обсуждения
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>
On 13/09/10 19:48, Tom Lane wrote: > Gaetano Mendola 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. You could check for volatile functions. I think this could be done safely. However, it doesn't seem worthwhile, it would be a fair amount of code, and it's not usually a good idea to put an ORDER BY in a view or subquery anyway unless you also have volatile functions in there, or you want to coerce the optimizer to choose a certain plan. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com
В списке pgsql-performance по дате отправления