Re: Faster "SET search_path"
Robert Haas <robertmhaas@gmail.com>
From: Robert Haas <robertmhaas@gmail.com>
To: Jeff Davis <pgsql@j-davis.com>
Cc: Nathan Bossart <nathandbossart@gmail.com>,
Isaac Morland <isaac.morland@gmail.com>, pgsql-hackers@postgresql.org
Date: 2023-08-15T17:04:45Z
Lists: pgsql-hackers
On Mon, Aug 7, 2023 at 7:24 PM Jeff Davis <pgsql@j-davis.com> wrote: > I might just avoid guc.c entirely and directly set > namespace_search_path and baseSearchPathValid=false. The main thing we > lose there is the GUC stack (AtEOXact_GUC()), but there's already a > PG_TRY/PG_FINALLY block in fmgr_security_definer, so we can use that to > change it back safely. (I think? I need to convince myself that it's > safe to skip the work in guc.c, at least for the special case of > search_path, and that it won't be too fragile.) I suspect that dodging the GUC stack machinery is not a very good idea. The timing of when TRY/CATCH blocks are called is different from when subtransactions are aborted, and that distinction has messed me up more than once when trying to code various things. Specifically, changes that happen in a CATCH block happen before we actually reach Abort(Sub)Transaction, which sort of makes it sound like you'd be reverting back to the old value too early. The GUC stack is also pretty complicated because of the SET/SAVE and LOCAL/non-LOCAL stuff. I can't say there isn't a way to make something like what you're talking about here work, but I bet it will be difficult to get all of the corner cases right, and I suspect that trying to speed up the existing mechanism is a better plan than trying to go around it. -- Robert Haas EDB: http://www.enterprisedb.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