Re: Faster "SET search_path"
Jeff Davis <pgsql@j-davis.com>
From: Jeff Davis <pgsql@j-davis.com>
To: Nathan Bossart <nathandbossart@gmail.com>
Cc: pgsql-hackers@postgresql.org
Date: 2023-08-03T06:50:28Z
Lists: pgsql-hackers
Attachments
- v3-0001-Transform-proconfig-for-faster-execution.patch (text/x-patch) patch v3-0001
- v3-0002-Optimize-check_search_path.patch (text/x-patch) patch v3-0002
- v3-0003-Add-cache-for-recomputeNamespacePath.patch (text/x-patch) patch v3-0003
On Tue, 2023-08-01 at 21:52 -0700, Nathan Bossart wrote:
> I
> typically see this done with two ѕeparate lists and forboth().
Agreed, done.
>
> Any reason not to use hash_combine() here?
Thank you, fixed.
> > I changed it to move the hook so that it's called after retrieving
> > from
> > the cache.
...
> I think you are right. This adds some complexity, but I don't have
> anything else to propose at the moment.
I reworked it a bit to avoid allocations in most cases, and it only
reprocesses the oidlist and runs the hooks when necessary (and even
then, still benefits from the cached OIDs that have already passed the
ACL checks).
Now I'm seeing timings around 7.1s, which is starting to look really
nice.
>
> I'm not following why this logic was moved.
There was previously a comment:
"We want to detect the case where the effective value of the base
search path variables didn't change. As long as we're doing so, we can
avoid copying the OID list unnecessarily."
But with v2 the copy had already happened by that point. In v3, there
is no copy at all.
>
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