Re: Patch: plan invalidation vs stored procedures
Martin Pihlak <martin.pihlak@gmail.com>
From: Martin Pihlak <martin.pihlak@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Alvaro Herrera <alvherre@commandprompt.com>, Dimitri Fontaine <dfontaine@hi-media.com>, Bruce Momjian <bruce@momjian.us>, Joshua Drake <jd@commandprompt.com>, Gregory Stark <stark@enterprisedb.com>, Hannu Krosing <hannu@2ndQuadrant.com>, Asko Oja <ascoja@gmail.com>, Pavel Stehule <pavel.stehule@gmail.com>, pgsql-hackers@postgresql.org, Andrew Dunstan <andrew@dunslane.net>, David Fetter <david@fetter.org>
Date: 2008-08-28T09:32:14Z
Lists: pgsql-hackers
Attachments
- plan-inval-proc.patch (text/x-diff) patch
Tom Lane wrote: > I hadn't read it yet, but that makes it wrong already. There's no need > for any new inval traffic --- the existing syscache inval messages on > pg_proc entries should serve fine. Yes, creating a new message type was a bit short sighted -- attached is a patch that uses syscache invalidation messages instead. This also adds additional tupleId field to SharedInvalCatcacheMsg. This is used to identify the invalidated tuple in PROC messages, for now others still pass InvalidOid. > More generally, if we are to try to invalidate on the strength of > pg_proc changes, what of other DDL changes? Operators, operator > classes, maybe? How about renaming a schema? I would like to see a > line drawn between things we find worth trying to track and things we > don't. If there is no such line, we're going to need a patch a lot > larger than this one. The attached patch registers callbacks for namespace, operator and op family catalog changes. PlanCacheCallback now takes catalog id as arg and can take actions depending on the catalog type. Adding new catalogs is just a matter of registering the callback in InitPlanCache. Of course, only tables and functions have exact tracking -- other changes just invalidate all. I'm wondering if the list of catalogs to be tracked should be fixed at all. Maybe it would be better to call PlanCacheCallback directly on any syscache entry invalidation? This way no catalog would be overlooked and the cache_callback_list could be kept nice and short. PlanCacheCallback would receive the catalog id and OID of the invalidated tuple and could then decide whether it can do precise invalidation, flush the cache or just skip the event. What do you think? regards, Martin