Re: Faster "SET search_path"
Jeff Davis <pgsql@j-davis.com>
From: Jeff Davis <pgsql@j-davis.com>
To: Noah Misch <noah@leadboat.com>
Cc: Nathan Bossart <nathandbossart@gmail.com>, Isaac Morland <isaac.morland@gmail.com>, pgsql-hackers@postgresql.org
Date: 2024-07-08T23:39:21Z
Lists: pgsql-hackers
Attachments
- v1-0001-Fix-missing-invalidations-for-search_path-cache.patch (text/x-patch) patch v1-0001
On Sun, 2024-06-30 at 15:30 -0700, Noah Misch wrote: > You're caching the result of object_aclcheck(NamespaceRelationId, > ...), so > pg_auth_members changes Thank you for the report. Question: to check for changes to pg_auth_members, it seems like either AUTHMEMROLEMEM or AUTHMEMMEMROLE work, and to use both would be redundant. Am I missing something, or should I just pick one arbitrarily (or by some convention)? > and pg_database changes also need to invalidate this > cache. (pg_database affects the ACL_CREATE_TEMP case in > pg_namespace_aclmask_ext() I am having trouble finding an actual problem with ACL_CREATE_TEMP. search_path ACL checks are normally bypassed for the temp namespace, so it can only happen when the actual temp namespace name (e.g. pg_temp_NNN) is explicitly included. In that case, the mask is ACL_USAGE, so the two branches in pg_namespace_aclmask_ext() are equivalent, right? This question is not terribly important for the fix, because invalidating for each pg_database change is still necessary as you point out in here: > and affects ROLE_PG_DATABASE_OWNER membership.) Another good catch, thank you. Patch attached. Contains a bit of cleanup and is intended for 17+18. Regards, Jeff Davis
Commits
-
Fix missing invalidations for search_path cache.
- b3bd18294ee4 18.0 landed
- d3e076549b99 17.0 landed
-
Optimize SearchPathCache by saving the last entry.
- a86c61c9eefa 17.0 landed
-
Optimize check_search_path() by using SearchPathCache.
- ad57c2a7c586 17.0 landed
-
Be more paranoid about OOM in search_path cache.
- 8efa301532c8 17.0 landed
-
Add cache for recomputeNamespacePath().
- f26c2368dcae 17.0 landed
-
Transform proconfig for faster execution.
- 5765cfe18c59 17.0 landed