From: | Ron <ronljohnsonjr(at)gmail(dot)com> |
---|---|
To: | pgsql-general list <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Example code Re: Singleton SELECT inside cursor loop |
Date: | 2022-10-01 17:25:50 |
Message-ID: | d652ade6-183f-2fa2-bd00-f92cdb63169d@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 10/1/22 07:21, Christoph Moench-Tegeder wrote:
> ## Ron (ronljohnsonjr(at)gmail(dot)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
The question then is "why am I just now seeing the problem?" We've been
using v12 for two years, and it just happened.
The only recent change is that I upgraded it from RDS 12.10 to 12.11 a
couple of weeks ago.
> And your functions create prepared statements under the hood:
> https://www.postgresql.org/docs/12/plpgsql-implementation.html#PLPGSQL-PLAN-CACHING
The same thing happens when I put the SELECT in a prepared statement, so
that seems the likely cause.
> 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.
That solved the problem. Thank you!
--
Angular momentum makes the world go 'round.
From | Date | Subject | |
---|---|---|---|
Next Message | Bryn Llewellyn | 2022-10-01 18:57:58 | Re: Names of run-time configuration parameters (was: Limiting the operations that client-side code can perform upon its database backend's artifacts) |
Previous Message | Ron | 2022-10-01 17:13:34 | Re: Example code Re: Singleton SELECT inside cursor loop |