Thread: Vacuum, statistics, & trigger/procedure query plan caching

Vacuum, statistics, & trigger/procedure query plan caching

From
"Karl O. Pinc"
Date:
Hi,

IIRC I once figured out that, for triggers at least,
query plans are cached with the connection.
This means that vacuuming and thus alterations
in the statistics do not take effect until
a connection is broken and re-established.

Mostly.  At least for triggers.  I think.
(In 7.4?)

I can't seem to find documentation on the
caching of query plans.  And in any case
it would be nice to have that information
linked to from the "periodic database maintenance
tasks" page that explains vacuuming.

Would it be possible/sensible to put a timestamp
on the cached query plans and compare that with
a timestamp on the last vacuum of the relevant
tables so that the query plans can be regenerated
if done from out of date statistics?
(Might that make it possible to plan queries less
often by disassociating the trigger query plan cache
from the connection?)

Out of date query plans don't often matter
but when they do they matter a lot.

Regards,

Karl <kop@meme.com>
Free Software:  "You don't pay back, you pay forward."
                 -- Robert A. Heinlein