On Tue, Nov 14, 2023 at 08:13:25PM -0800, Jeff Davis wrote: > On Thu, 2023-10-19 at 19:01 -0700, Jeff Davis wrote: > > 0003: Cache for recomputeNamespacePath. > > Committed
Commit f26c236 wrote: > Add cache for recomputeNamespacePath(). > > When search_path is changed to something that was previously set, and > no invalidation happened in between, use the cached list of namespace > OIDs rather than recomputing them. This avoids syscache lookups and > ACL checks. > --- a/src/backend/catalog/namespace.c > +++ b/src/backend/catalog/namespace.c > @@ -109,11 +110,13 @@ > * activeSearchPath is always the actually active path; it points to > * to baseSearchPath which is the list derived from namespace_search_path. > * > - * If baseSearchPathValid is false, then baseSearchPath (and other > - * derived variables) need to be recomputed from namespace_search_path. > - * We mark it invalid upon an assignment to namespace_search_path or receipt > - * of a syscache invalidation event for pg_namespace. The recomputation > - * is done during the next lookup attempt. > + * If baseSearchPathValid is false, then baseSearchPath (and other derived > + * variables) need to be recomputed from namespace_search_path, or retrieved > + * from the search path cache if there haven't been any syscache > + * invalidations. We mark it invalid upon an assignment to > + * namespace_search_path or receipt of a syscache invalidation event for > + * pg_namespace or pg_authid. The recomputation is done during the next You're caching the result of object_aclcheck(NamespaceRelationId, ...), so pg_auth_members changes and pg_database changes also need to invalidate this cache. (pg_database affects the ACL_CREATE_TEMP case in pg_namespace_aclmask_ext() and affects ROLE_PG_DATABASE_OWNER membership.)