pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Noah Misch <noah@leadboat.com>
To: Jeff Davis <pgsql@j-davis.com>
Cc: Nathan Bossart <nathandbossart@gmail.com>
Cc: Isaac Morland <isaac.morland@gmail.com>
Cc: pgsql-hackers@postgresql.org
Subject: Re: Faster "SET search_path"
Date: Sun, 30 Jun 2024 15:30:47 -0700
Message-ID: <20240630223047.1f.nmisch@google.com> (raw)
In-Reply-To: <695668acc40b937258985669f3d55b94cce82c3c.camel@j-davis.com>
References: <CAMsGm5fZ2xiVDLYH4-_Ld8bfe1qwY23ZLgPc7zBpH8d1WUw70A@mail.gmail.com>
	<f555c41554c7f5ff2699c085836ea94beac09bad.camel@j-davis.com>
	<20230802050720.GB866741@nathanxps13>
	<CAMsGm5dt6szoTe5oAzk5nfbHHOEpMDVhLTOGWCJGCQ3Wq8+J0w@mail.gmail.com>
	<fec7f3bea50112323d9b6e700b5e2762a14af809.camel@j-davis.com>
	<20230807223908.GB1284531@nathanxps13>
	<3b2d57ead15798adcbf6a53a15e35cdbadb2c147.camel@j-davis.com>
	<5bb4d9c21cc918e5d05021bf0d5e0e7d34a0377c.camel@j-davis.com>
	<abf4ce8804e0e05dff8c1725ae6a8ed28b7d66e0.camel@j-davis.com>
	<695668acc40b937258985669f3d55b94cce82c3c.camel@j-davis.com>

On Tue, Nov 14, 2023 at 08:13:25PM -0800, Jeff Davis wrote:
> On Thu, 2023-10-19 at 19:01 -0700, Jeff Davis wrote:
> > 0003: Cache for recomputeNamespacePath.
> 
> Committed

Commit f26c236 wrote:
>     Add cache for recomputeNamespacePath().
>     
>     When search_path is changed to something that was previously set, and
>     no invalidation happened in between, use the cached list of namespace
>     OIDs rather than recomputing them. This avoids syscache lookups and
>     ACL checks.

> --- a/src/backend/catalog/namespace.c
> +++ b/src/backend/catalog/namespace.c

> @@ -109,11 +110,13 @@
>   * activeSearchPath is always the actually active path; it points to
>   * to baseSearchPath which is the list derived from namespace_search_path.
>   *
> - * If baseSearchPathValid is false, then baseSearchPath (and other
> - * derived variables) need to be recomputed from namespace_search_path.
> - * We mark it invalid upon an assignment to namespace_search_path or receipt
> - * of a syscache invalidation event for pg_namespace.  The recomputation
> - * is done during the next lookup attempt.
> + * If baseSearchPathValid is false, then baseSearchPath (and other derived
> + * variables) need to be recomputed from namespace_search_path, or retrieved
> + * from the search path cache if there haven't been any syscache
> + * invalidations.  We mark it invalid upon an assignment to
> + * namespace_search_path or receipt of a syscache invalidation event for
> + * pg_namespace or pg_authid.  The recomputation is done during the next

You're caching the result of object_aclcheck(NamespaceRelationId, ...), so
pg_auth_members changes and pg_database changes also need to invalidate this
cache.  (pg_database affects the ACL_CREATE_TEMP case in
pg_namespace_aclmask_ext() and affects ROLE_PG_DATABASE_OWNER membership.)





view thread (28+ messages)  latest in thread

Message-ID: <20240630223047.1f.nmisch@google.com>
Permalink:  ../20240630223047.1f.nmisch@google.com/
Also on:    postgresql.org/message-id/20240630223047.1f.nmisch@google.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: noah@leadboat.com, pgsql@j-davis.com, nathandbossart@gmail.com, isaac.morland@gmail.com
  Subject: Re: Faster "SET search_path"
  In-Reply-To: <20240630223047.1f.nmisch@google.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox