Re: Sorting. When?

Поиск
Список
Период
Сортировка
От Kevin Grittner
Тема Re: Sorting. When?
Дата
Msg-id 4D554BB1020000250003A8CC@gw.wicourts.gov
обсуждение исходный текст
Ответ на Re: Sorting. When?  ("mac_man2008@yahoo.it" <mac_man2008@yahoo.it>)
Ответы Re: Sorting. When?  (Nicolas Barbier <nicolas.barbier@gmail.com>)
Список pgsql-hackers
"mac_man2008@yahoo.it" <mac_man2008@yahoo.it> wrote:
> I need to know, from an algorithmic point of view, in which cases
> sorting is invoked.
Well, I think the only accurate answer to that is "when the
estimated cost of a plan using a sort is lower than the estimated
cost of any alternatives".  There are cases where you can be sure a
sort will be used, like when you have an ORDER BY clause and there
is no index which can scan rows in that order; but there are a lot
of situations where plans which involve sorts are in competition
with plans which don't.  The plan chosen can depend on such things
as how bloated your table is, how close the order of the tuples in
the heap corresponds to the order of a particular index, how many
rows are in which tables, what work_mem is set to, etc.
Are your really looking to categorize the types of queries where
sorting is *invoked*, or the ones where it is *considered*?  Or
perhaps only those where it is *required*, since there are no
possible plans without sorting?
-Kevin


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Gurjeet Singh
Дата:
Сообщение: Fix for Index Advisor related hooks
Следующее
От: Tom Lane
Дата:
Сообщение: Re: ALTER EXTENSION UPGRADE, v3