Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1twbdi-00Fwf0-VA for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Mar 2025 06:50:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1twbdg-00EeHg-LC for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Mar 2025 06:50:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1twbdg-00EeHX-A1 for pgsql-hackers@lists.postgresql.org; Mon, 24 Mar 2025 06:50:24 +0000 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1twbdd-000ooS-1n for pgsql-hackers@lists.postgresql.org; Mon, 24 Mar 2025 06:50:23 +0000 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-ac29fd22163so691148766b.3 for ; Sun, 23 Mar 2025 23:50:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742799020; x=1743403820; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=YIKjDsD+xQOcEq6T2EPAgaZjavhk69h8jRZczvMCyOM=; b=gsk6DXXHTjh+aDhNGFCB3SfmfImkhcAX1bSNsq4U6ttARwhaElvHM/CLFO+qok5D7d ewtjMWmZkXBySsCrqFCdJL99IgRgqTBqZPFNrALAWOlHHdFFR2KashnI/YdeM/qpwml3 4qlvr7iIsV/lPEhUQ+ABQi2zcnEGofSFypMNKYDIlr75/qXJyPXAOWFV+GTkOr3WTs5R V85TSwsraVyr9ykA0nbkjxHZoaIBQ11kC8DRGqf7Jt4wyVEMxw6ppqJSWFUCre5OLzxP BgiHAsGRBOruwDQYFyw2zJ6gNUGCP5y3xRS/XAZJNmDXgrJxOXoYA7IAN9KswT8DXsec Q+lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742799020; x=1743403820; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YIKjDsD+xQOcEq6T2EPAgaZjavhk69h8jRZczvMCyOM=; b=SKuSAfeWDD7M7rbtsXWk1JzRntnXf6YQ66l5gEigVN1VTrQuXOdRresa8Ss0+XYHmc a5XtxJbz++Q3gWDeD0k49geArqFKIVvScGQXFQ6sPLKlPKLzzUHmDs6gOQzH5RzcE3Wo HyfX4odofkL71qr/RqgqxUr4rxAPT3dBuMnJh7r8rbeYXAhjZHhP6xJXq3QbNWUDcmoE N9GhlCum+oxB6eZqQ/k5xoEB+NeRvHBsE9RKdD9N/OZ9qOt2fbsMDR87NwVJbq+xLxMz xX+F6+Xg8ko1S8B35amFtQ9XyJSCf3tlyHpXXNrX5Dw8bHbOzxf/PHtfB+nzrFHR3utC IXMA== X-Gm-Message-State: AOJu0Ywanwgb1Vk14WvhSoGx7hMZEEi753eYyg7nP3r0PJZNzQWzjzBQ w8WFgqeJoecrlDlTqXzSFQYjQYzcDbo13sgrrUv1LOVCLe15f45zMU/hoszsKxM8CTgaUBHtc0N QE2rnpSz62B9m37U3CRmiT4mrDdaecrrSNXA8AA== X-Gm-Gg: ASbGncsCkjkd2u3BN06V98A0lFx3rBBRcQLnlAr724E+YoRVobqIGb6Uqs1DYqIDunC 7RBnZMs0vTsHKNlB7uVsd+2+szsBiz9H2gQNSUijrWLVsxMPznCgWeffrJis0clrfYexXfJh4sp 6yOK5VPOCksTdxH9RsNKbIVlCfDQ== X-Google-Smtp-Source: AGHT+IE4KmFjPE2lcGlkgRadhsMqrgjn9RxGyNUXehDObWY9AX0Ah9l9ZR2a7OoKZ8w4il2sS2BN5NH/Bzbtyf0KJ4w= X-Received: by 2002:a17:907:8694:b0:ac3:b277:2474 with SMTP id a640c23a62f3a-ac3f2285fcdmr1224255166b.28.1742799019859; Sun, 23 Mar 2025 23:50:19 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Tender Wang Date: Mon, 24 Mar 2025 14:50:08 +0800 X-Gm-Features: AQ5f1Jq7cKZZjGa4DMLZ2Ls07-QEKHBYHwNQmjCRjcIRL-3P4zndB5Q4X2eOhmk Message-ID: Subject: Re: Add mention in docs about locking all partitions for generic plans To: David Rowley Cc: PostgreSQL Developers Content-Type: multipart/alternative; boundary="0000000000007e66750631110475" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000007e66750631110475 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable David Rowley =E4=BA=8E2025=E5=B9=B43=E6=9C=8824=E6= =97=A5=E5=91=A8=E4=B8=80 05:28=E5=86=99=E9=81=93=EF=BC=9A > Over in [1], there was some uncertainty about whether locking an > unrelated partition was expected behaviour or not for the particular > use-case which used a generic plan to scan a partitioned table and all > of the partitions. > > I noticed that we don't mention this in the docs and though that > perhaps we should. I thought a good place might be in [2] at the end > of the following paragraph: > > "During initialization of the query plan. Partition pruning can be > performed here for parameter values which are known during the > initialization phase of execution. Partitions which are pruned during > this stage will not show up in the query's EXPLAIN or EXPLAIN ANALYZE. > It is possible to determine the number of partitions which were > removed during this phase by observing the =E2=80=9CSubplans Removed=E2= =80=9D property > in the EXPLAIN output." > > Perhaps adding something like "Because all relations which are part of > the plan are locked at the beginning of execution, any partitions > pruned at this stage are already locked and will remain so until the > end of the transaction.". > > or: > > "It's important to note that any partitions removed by the partition > pruning done at this stage are still locked at the beginning of > execution". > I prefer this. > > This is no longer true in master, so if we do something here it's only > v17 and earlier. > In the case of [1], we still have AccessShareLock on entity_2, even though it is pruned during initial partition pruning. This seems to contradict what you said. "This is no longer true in master" . [1] https://postgr.es/m/01020195b987abd3-a008b77d-8c63-4931-80a4-be36a351c8b2-0= 00000@eu-west-1.amazonses.com --=20 Thanks, Tender Wang --0000000000007e66750631110475 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


David Rowley &l= t;dgrowleyml@gmail.com> =E4= =BA=8E2025=E5=B9=B43=E6=9C=8824=E6=97=A5=E5=91=A8=E4=B8=80 05:28=E5=86=99= =E9=81=93=EF=BC=9A
Over in [1], there was some uncertainty about whether locking an
unrelated partition was expected behaviour or not for the particular
use-case which used a generic plan to scan a partitioned table and all
of the partitions.

I noticed that we don't mention this in the docs and though that
perhaps we should. I thought a good place might be in [2] at the end
of the following paragraph:

"During initialization of the query plan. Partition pruning can be
performed here for parameter values which are known during the
initialization phase of execution. Partitions which are pruned during
this stage will not show up in the query's EXPLAIN or EXPLAIN ANALYZE.<= br> It is possible to determine the number of partitions which were
removed during this phase by observing the =E2=80=9CSubplans Removed=E2=80= =9D property
in the EXPLAIN output."

Perhaps adding something like "Because all relations which are part of=
the plan are locked at the beginning of execution, any partitions
pruned at this stage are already locked and will remain so until the
end of the transaction.".

or:

"It's important to note that any partitions removed by the partiti= on
pruning done at this stage are still locked at the beginning of
execution".

I prefer this.
=C2=A0

This is no longer true in master, so if we do something here it's only<= br> v17 and earlier.
=C2=A0
In the case of [1], = we still have AccessShareLock on entity_2, even though it is pruned during = initial partition pruning.
This seems to contradict what you said= .=C2=A0 "This is no longer true in master" .=C2=A0=C2=A0




--
=
Thanks,
Tender Wang
--0000000000007e66750631110475--