Re: limit and query planner

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: limit and query planner
Дата
Msg-id 9055.1528225349@sss.pgh.pa.us
обсуждение исходный текст
Ответ на limit and query planner  (armand pirvu <armand.pirvu@gmail.com>)
Ответы Re: limit and query planner
Список pgsql-general
armand pirvu <armand.pirvu@gmail.com> writes:
> My question is: I suspect the limit simply limits the fethching to the first n-records retrieved and has no
implicationswhatsoever on the planner, meaning the planner ignores it. Am I right or wrong ? 

You're quite wrong.  The presence of a LIMIT causes the planner to prefer
"fast start" plans, since it will then optimize on the basis of picking
the lowest estimated cost to fetch the first N rows.  As an example,
you're more likely to get an ordered indexscan than a seqscan-and-sort
for small N, though there are many cases where seqscan-and-sort wins
if the need is to fetch the whole table.

            regards, tom lane


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

Предыдущее
От: Chris Travers
Дата:
Сообщение: Re: Code of Conduct plan
Следующее
От: Benjamin Scherrey
Дата:
Сообщение: Re: Code of Conduct plan