Re: Delay locking partitions during query execution

From: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Delay locking partitions during query execution
Date: 2019-02-19 00:18:48
Message-ID: CAKJS1f9drwMDPTUhW=4hK=u-fiVoN3ix1nTSgYFLxqzxYvz3=A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 19 Feb 2019 at 12:50, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> [ reposting some questions asked in the wrong thread ]
>
> What I'd like to understand about this patch is how it relates
> to Amit L.'s work on making the planner faster for partitioned
> UPDATE/DELETE cases (https://commitfest.postgresql.org/22/1778/).
> I think that that might render this moot? Amit's already
> getting rid of unnecessary partition locking.

(I'm still not certain of this patch myself and it does need me to do
some more analysis to check on what was mentioned recently upthread,
but...)

As for the overlap with Amit's patch, it is true he's reducing the
locking down to just non-pruned partitions, so for this patch, that
only leaves us able to skip locking partitions that are about to be
run-time pruned. That happens to be quite useful when using generic
plans as it's quite possible that the planner is unable to prune any
partitions and the executor would otherwise have to lock all of them,
but perhaps only end up scanning 1 of them. It's true that when
plan_cache_mode = auto that a generic plan doing this is unlikely to
ever be chosen since the planner does not cost in the possibility of
run-time pruning, but there's also plan_cache_mode =
force_generic_plan.

> In any case, I'd counsel against putting planner outputs into
> RangeTblEntry. Someday we ought to make parse trees read-only
> to the planner, as plan trees are to the executor; defining them
> to carry planner results kneecaps any such effort before it starts.
> Not to mention the unpleasant consequences for the footprint
> of this patch.

I agree that one day it would be nice to move towards having the
planner never touch the parse, but I didn't really see it as anything
much beyond what rellockmode is today. If we one day have a solution
for that, then likely the same solution will support fixing the
delaylock flag too.

--
David Rowley http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2019-02-19 00:20:12 Re: Speed up transaction completion faster after many relations are accessed in a transaction
Previous Message Andres Freund 2019-02-19 00:16:39 Re: Speed up transaction completion faster after many relations are accessed in a transaction