Re: Delay locking partitions during INSERT and UPDATE

Robert Haas <robertmhaas@gmail.com>

From: Robert Haas <robertmhaas@gmail.com>
To: David Rowley <david.rowley@2ndquadrant.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Andres Freund <andres@anarazel.de>, Tomas Vondra <tomas.vondra@2ndquadrant.com>, John Naylor <john.naylor@2ndquadrant.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2019-02-20T15:42:56Z
Lists: pgsql-hackers
On Tue, Feb 19, 2019 at 4:07 PM David Rowley
<david.rowley@2ndquadrant.com> wrote:
> I'd say that here we should only discuss what this patch is doing, ...

On that note, I spent some more time looking at what the patch is doing today.

     /*
      * We locked all the partitions in ExecSetupPartitionTupleRouting
      * including the leaf partitions.
      */
-    partrel = table_open(dispatch->partdesc->oids[partidx], NoLock);
+    partrel = table_open(dispatch->partdesc->oids[partidx], RowExclusiveLock);

It seems to me that the reason for this change is precisely that the
comment is now false, and therefore the comment needs to be updated.

Does that sound right?

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


Commits

  1. Delay lock acquisition for partitions until we route a tuple to them.