Re: Lock acquisition for partition table when setting generic plan - Mailing list pgsql-general

From Tom Lane
Subject Re: Lock acquisition for partition table when setting generic plan
Date
Msg-id 2183.1579100950@sss.pgh.pa.us
Whole thread Raw
In response to Lock acquisition for partition table when setting generic plan  ("yotsunaga.naoki@fujitsu.com" <yotsunaga.naoki@fujitsu.com>)
List pgsql-general
"yotsunaga.naoki@fujitsu.com" <yotsunaga.naoki@fujitsu.com> writes:
> I did the following.
> Even though I accessed one partition table(test2 table), I also acquired locks on other partition tables(test1
table).
> I expected to acquire locks on the parent table(test table) and the partition table to access(test2 table).
> Why does this happen?

You specified a generic plan:

> postgres=# set plan_cache_mode = force_generic_plan ;

so you are not going to get any plan-time optimization based on knowing
the id parameter.  Therefore the plan must include sub-plan nodes for
every child table, so executing it requires locking all those tables
to make sure their schemas haven't changed.

            regards, tom lane



pgsql-general by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: Lock leaking out of Transaction?
Next
From: Kasun Kulathunga
Date:
Subject: Upgrading from 9.6 to 12