Re: expensive function in select list vs limit clause

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: expensive function in select list vs limit clause
Дата
Msg-id 7205.1491402576@sss.pgh.pa.us
обсуждение исходный текст
Ответ на expensive function in select list vs limit clause  (Chris Mair <chris@1006.org>)
Ответы Re: expensive function in select list vs limit clause
Список pgsql-general
Chris Mair <chris@1006.org> writes:
>  From the timings it appears that in the second explain analyze query a function
> call in the select list (expensive()) is evaluated in the sequential scan node
> *for each* row in big, despite the use of limit.

According to the SQL standard, the SELECT list is evaluated before ORDER
BY, so if you need an explicit sort step the function is going to get
calculated first.  This is obviously necessary if the function is used
as the sort key, but otherwise it's possible to be smarter.  We were not
smarter before 9.6 though.  You might find this commit message informative:

https://git.postgresql.org/gitweb/?p=postgresql.git&a=commitdiff&h=9118d03a8

            regards, tom lane


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

Предыдущее
От: vinny
Дата:
Сообщение: Re: browser interface to forums please?
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: browser interface to forums please?