From: | Sami Imseih <samimseih(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | should num_custom_plans be reset after plan invalidation? |
Date: | 2025-03-05 14:27:35 |
Message-ID: | CAA5RZ0sYt1GFwMC2ysKxPFfErOj6w8UXbpo=mkx-waCsd8P5hg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
While examining plan caches, I noticed that when a generic plan is invalidated,
the next execution of the prepared statement still results in a
generic plan. This
is of course with the default plan_cache_mode.
This behavior might go unnoticed since plan cache invalidations are
relatively uncommon,
but I’m unsure if this is the intended design. The existing decision
to switch to
a generic plan—based on the cost average of the first five custom
plans—may no longer
be optimal after a relation is modified (e.g., when a new index is added).
Given this, resetting num_custom_plans to 0 after a plan cache invalidation
might be a better approach.
I've attached an example for reference. The fix seems straightforward,
but since generic
plans may already not handle skewed data optimally, I want to see if others have
thoughts on this being something to fix.
--
Sami Imseih
Amazon Web Services (AWS)
Attachment | Content-Type | Size |
---|---|---|
cache_invalidation.txt | text/plain | 7.2 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2025-03-05 14:33:35 | Announcing Release 19.1 of the PostgreSQL Buildfarm client |
Previous Message | Daniel Verite | 2025-03-05 14:25:12 | Re: Add Pipelining support in psql |