Sami Imseih <samimseih@gmail.com> writes:
> 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.
Yes, it is. There's little reason to expect that the invalidation
would change our decision, and re-planning five times to confirm that
is a high price to pay.
Sure, the invalidation *might* have been because of a new index
that happens to fit the query, but the odds of that seem small to me.
It's much more likely because of auto-vacuum tweaking the stats, or
just a random sinval queue overrun.
regards, tom lane