Re: Example code Re: Singleton SELECT inside cursor loop

Поиск
Список
Период
Сортировка
От Christoph Moench-Tegeder
Тема Re: Example code Re: Singleton SELECT inside cursor loop
Дата
Msg-id Yzgwu2MHvqlfkdwH@elch.exwg.net
обсуждение исходный текст
Ответ на Example code Re: Singleton SELECT inside cursor loop  (Ron <ronljohnsonjr@gmail.com>)
Ответы Re: Example code Re: Singleton SELECT inside cursor loop  (Ron <ronljohnsonjr@gmail.com>)
Список pgsql-general
## Ron (ronljohnsonjr@gmail.com):

> Note how quickly it runs the first five times, but takes 780x longer the 
> sixth time I run it.  Exiting psql and entering again causes the same 
> slowness the sixth time it's run.

Tanks at the sixth time? That rings a bell: "The current rule for this
is that the first five executions are done with custom plans[...]" from
https://www.postgresql.org/docs/12/sql-prepare.html
And your functions create prepared statements under the hood:
https://www.postgresql.org/docs/12/plpgsql-implementation.html#PLPGSQL-PLAN-CACHING
I guess you should visit
https://www.postgresql.org/docs/12/runtime-config-query.html#GUC-PLAN-CACHE_MODE
and try if plan_cache_mode = force_custom_plan helps here.

Regards,
Christoph

-- 
Spare Space



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

Предыдущее
От: "Peter J. Holzer"
Дата:
Сообщение: Re: Example code Re: Singleton SELECT inside cursor loop
Следующее
От: Julien Rouhaud
Дата:
Сообщение: Re: Names of run-time configuration parameters (was: Limiting the operations that client-side code can perform upon its database backend's artifacts)