Re: Do function calls the cached?

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Do function calls the cached?
Дата
Msg-id CAKFQuwaaLDj7Rb1pVjHSdSaU6Q030zX6j1_g=VK-dNwDqXsArA@mail.gmail.com
обсуждение исходный текст
Ответ на Do function calls the cached?  (Daniel Caldeweyher <dcalde@gmail.com>)
Ответы Re: Do function calls the cached?  (Daniel Caldeweyher <dcalde@gmail.com>)
Список pgsql-general
On Tue, Aug 30, 2016 at 4:15 PM, Daniel Caldeweyher <dcalde@gmail.com> wrote:

select x,y,z, (extract_keywords(l.*)).*

​[...]​
 
Does this mean the function gets called three time?

​Yes.
 
(​function_call(...)).*​
 
​syntax is problematic.  You should avoid it via one of two options.

LATERAL (new way, preferred)
or
CTE​ (old way)

In the CTE version you make the call in the CTE but do "(col).*" in the main query.  This way the function is only called once to generate a composite output, then the composite output is exploded.

With LATERAL the system is smart enough to do it the right way.

David J.

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

Предыдущее
От: Daniel Caldeweyher
Дата:
Сообщение: Do function calls the cached?
Следующее
От: Chinh Nguyen
Дата:
Сообщение: Queries on async replicas locked each other after index rename on master