On Tue, 2023-08-15 at 13:04 -0400, Robert Haas wrote: > 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.
... > 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. The SearchPathCache that I implemented (0003) is an example of speeding up the existing mechnism that and already offers a huge speedup. I'll focus on getting that in first. That patch has had some review and I'm tempted to commit it soon, but Nathan has requested another set of eyes on it. To bring the overhead closer to zero we need to somehow avoid repeating so much work in guc.c, though. If we don't go around it, another approach would be to separate GUC setting into two phases: one that does the checks, and one that performs the final change. All the real work (hash lookup, guc_strdup, and check_search_path) is done in the "check" phase. It's a bit painful to reorganize the code in guc.c, though, so that might need to happen in a few parts and will depend on how great the demand is. Regards, Jeff Davis