Re: Create/alter policy and exclusive table lock

Tom Lane <[email protected]> Tue, 14 Jan 2020 12:40:56 -0500
Newsgroups gmane.comp.db.postgresql.devel.general
Message-ID <[email protected]>
Konstantin Knizhnik <[email protected]> writes:
> But let me ask you one more question: why do we obtaining snapshot twice 
> in exec_simple_query:
> first for analyze (pg_analyze_and_rewrite) and one for execution 
> (PortalStart)?

That would happen anyway if the plan is cached.  If we were to throw away
all plan caching and swear a mighty oath that we'll never put it back,
maybe we could build in a design assumption that planning and execution
use identical snapshots.  I doubt that would lead to a net win though.

Also note that our whole approach to cache invalidation is based on the
assumption that if session A needs to see the effects of session B,
they will be taking conflicting locks.  Otherwise sinval signaling
is not guaranteed to be detected at the necessary times.

			regards, tom lane