Re: Faster "SET search_path"
Nathan Bossart <nathandbossart@gmail.com>
From: Nathan Bossart <nathandbossart@gmail.com>
To: Jeff Davis <pgsql@j-davis.com>
Cc: pgsql-hackers@postgresql.org
Date: 2023-07-30T04:51:05Z
Lists: pgsql-hackers
On Sat, Jul 29, 2023 at 08:59:01AM -0700, Jeff Davis wrote: > 0001: Transform the settings in proconfig into a List for faster > processing. This is simple and speeds up any proconfig setting. This looks straightforward. It might be worth combining the common parts of ProcessGUCArray() and TransformGUCArray() if there is a clean way to do so. > 0002: Introduce CheckIdentifierString(), which is a faster version of > SplitIdentifierString() that only validates, and can be used in > check_search_path(). This also looks straightforward. And I'd make the same comment as above for SplitIdentifierString() and CheckIdentifierString(). Perhaps we could have folks set SplitIdentifierString's namelist argument to NULL to indicate that it only needs to validate. > 0003: Cache of previous search_path settings. The key is the raw > namespace_search_path string and the role OID, and it caches the > computed OID list. Changes to the search_path setting or the role can > retrieve the cached OID list as long as nothing else invalidates the > cache (changes to the temp schema or a syscache invalidation of > pg_namespace or pg_role). At a glance, this looks pretty reasonable, too. > One behavior change in 0003 is that retrieving a cached OID list > doesn't call InvokeNamespaceSearchHook(). It would be easy enough to > disable caching when a hook exists, but I didn't see a reason to expect > that "SET search_path" must invoke that hook each time. Invoking it > when computing for the first time, or after a real invalidation, seemed > fine to me. Feedback on that is welcome. Could a previously cached list be used to circumvent a hook that was just reconfigured to ERROR for certain namespaces? If something like that is possible, then we might need to disable the cache when there is a hook. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com
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