Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1irkIP-0003B6-8B for pgsql-general@arkaria.postgresql.org; Wed, 15 Jan 2020 15:09:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1irkIN-00039E-5L for pgsql-general@arkaria.postgresql.org; Wed, 15 Jan 2020 15:09:23 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1irkIM-000397-Is for pgsql-general@lists.postgresql.org; Wed, 15 Jan 2020 15:09:22 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1irkIG-0005kP-1w for pgsql-general@postgresql.org; Wed, 15 Jan 2020 15:09:20 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 00FF9ADM002184; Wed, 15 Jan 2020 10:09:11 -0500 From: Tom Lane To: "yotsunaga.naoki@fujitsu.com" cc: Pgsql-general Subject: Re: Lock acquisition for partition table when setting generic plan In-reply-to: References: Comments: In-reply-to "yotsunaga.naoki@fujitsu.com" message dated "Wed, 15 Jan 2020 02:58:45 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2182.1579100950.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 15 Jan 2020 10:09:10 -0500 Message-ID: <2183.1579100950@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk "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 part= ition table to access(test2 table). > Why does this happen? You specified a generic plan: > postgres=3D# set plan_cache_mode =3D 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