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 1twdxz-00GGDw-LU for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Mar 2025 09:19:31 +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 1twdxw-00GyjF-DE for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Mar 2025 09:19:28 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1twdxv-00Gygv-UF for pgsql-hackers@lists.postgresql.org; Mon, 24 Mar 2025 09:19:28 +0000 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1twdxu-000pRR-0v for pgsql-hackers@lists.postgresql.org; Mon, 24 Mar 2025 09:19:27 +0000 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-ab771575040so1011117766b.1 for ; Mon, 24 Mar 2025 02:19:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742807963; x=1743412763; 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=tLg1o2W+Cd0RdXkwHnt8mMKhlw+FlBjV2xKcZ7w/et8=; b=lTY6LHsUsaZ6TlmqqI9bxdjpfkBHT/cwGVlBRUwB7h0CL1bBWil5xbJZnpx+PkF2Nz IUH1HU613PwRrYFNHALRDaXv1hXjfD0Noc1gC139Unov2jP5DofCSPZqhYPIjjrGU+lb JotNpIujHzi6onjp9cnvVEyddDxQZmwTYuTTv1eGtD0MmKVqsr8ybIrtkM1+R4tOAeUp FJCUJNTUpEc7oR1EIpvHb9ACy6dmrzizfLEJC3yer6LVcOYetnficRKrmndPV2JwwHiF p9LTknpFzkn04Gy7wtzKeNVo3/k/qdGr37Jl7h5KB9tMcThNViEtuRWkzcwGb+aSBSKO cpCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742807963; x=1743412763; 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=tLg1o2W+Cd0RdXkwHnt8mMKhlw+FlBjV2xKcZ7w/et8=; b=gEFAUR8FCKbf/MyGc4Urk0Q2JCTeAkYo4nWYFAZBqCghRy4zjPF8o5+dnjVECcocrk 61dUOXxFhPLiOIZebjX51ykfmrEigsanV5VPL27G10BkKaMTNcs5eb2pM1lZst5Xz/t7 OMejkLhSOSubl5rZMKkl7tRNHntBDjx9jMErv+NdIzO0fdIhsOLijGrEVFXCDuOxI7R8 8rXxNJikZfC0IQjY1QCqasPUhdOS3DvbCWFIwkWHRRTUiX5GbX9qaNXpJD1w/YF8oBN/ HvYZJrutWCUNXbOXuclfOPeH6YAPw2ogK9ta8MOvQPFf1EtCTad5AKLyAzOuKkXZ+6ww aCAQ== X-Gm-Message-State: AOJu0Yy9NLIkhwPUKtyIVSdEmcZkEgZ4g9nn3CJ/G5GFkLXZB9cE+b6v tgl0Mk0404ko0Wkz6uiVOxvROagMF/YCVE9WavRbW40Qogj/hTtrlOUUG51skGKL4PYNf/fCLdR TXgsSvht/14prILAGpOxFumLreHU= X-Gm-Gg: ASbGncvMCz5cpRXzd1p9h6/Wcj3ZTWlJ3s3xunNLPsRHS9oU2Y7bkmYUVEiZg2YCGKF j3OrLjbENiHcJ1p5irxWI0cpEINxEQnWYUWbupIAqZqvsT9Pzf50tqDSF2asJXRlYzAVdpDHM8b I/d5gDshskHq6i20uytDkuAZ1/8hTFHzCo X-Google-Smtp-Source: AGHT+IEh5MshIzZ7s7W0D3S2cYCQEJ98PR6JHMt3Do3eJxKVTmKqvOcxAo7ew56ojAbYxQBQ3vDmYvEtXRc0J0MafQg= X-Received: by 2002:a17:907:86a7:b0:ac3:c6a2:a02d with SMTP id a640c23a62f3a-ac3cdb95075mr1677407966b.7.1742807963352; Mon, 24 Mar 2025 02:19:23 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Tender Wang Date: Mon, 24 Mar 2025 17:19:12 +0800 X-Gm-Features: AQ5f1JpQCpx5vtJwDDYrbe_tW3i7RdDZzNPzYUQRdehFDvkV7TFoy9lz3FrHCPQ 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="00000000000091493c06311319b4" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000091493c06311319b4 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 16:50=E5=86=99=E9=81=93=EF=BC=9A > On Mon, 24 Mar 2025 at 19:50, Tender Wang wrote: > > > > 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 > >> 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" . > > For that particular case, planning occurs each time prior to execution > and it's the planner that takes the lock, not the executor. If you > want to not plan each time then you could modify that case to use a > plpgsql function instead of sql and then ensure you're using a cached > plan with "set plan_cache_mode =3D force_generic_plan;" (apparently we > don't cache plans for non-inlined SQL functions). I disagree that this > makes the proposed sentence untrue. 525392d57 did change the order of > operations here so that the partitions in the Append/MergeAppend are > locked after run-time pruning occurs at executor startup. > Thanks for the explanation. > > Maybe I was wrong about writing nothing in master's docs. It might > still be important to detail this. I don't know the best way to phrase > that, but maybe something along the lines of: "The query planner > obtains locks for all partitions which are part of the plan. However, > when the executor uses a cached plan, locks are only obtained on the > partitions which remain after partition pruning done during the > initialization phase of execution, i.e., the ones shown in the EXPLAIN > output and not the ones referred to by the =E2=80=9CSubplans Removed=E2= =80=9D > property.". > > Any opinions? > The above sentence looks good to me. --=20 Thanks, Tender Wang --00000000000091493c06311319b4 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 16:50=E5=86=99= =E9=81=93=EF=BC=9A
On Mon, 24 Mar 2025 at 19:50, Tender Wang <tndrwang@gmail.com> wrote:
>
> David Rowley <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
>> This is no longer true in master, so if we do something here it= 9;s only
>> v17 and earlier.
>
> In the case of [1], we still have AccessShareLock on entity_2, even th= ough it is pruned during initial partition pruning.
> This seems to contradict what you said.=C2=A0 "This is no longer = true in master" .

For that particular case, planning occurs each time prior to execution
and it's the planner that takes the lock, not the executor. If you
want to not plan each time then you could modify that case to use a
plpgsql function instead of sql and then ensure you're using a cached plan with "set plan_cache_mode =3D force_generic_plan;" (apparent= ly we
don't cache plans for non-inlined SQL functions). I disagree that this<= br> makes the proposed sentence untrue. 525392d57 did change the order of
operations here so that the partitions in the Append/MergeAppend are
locked after run-time pruning occurs at executor startup.
<= div>
Thanks for the explanation.=C2=A0

Maybe I was wrong about writing nothing in master's docs. It might
still be important to detail this. I don't know the best way to phrase<= br> that, but maybe something along the lines of: "The query planner
obtains locks for all partitions which are part of the plan.=C2=A0 However,=
when the executor uses a cached plan, locks are only obtained on the
partitions which remain after partition pruning done during the
initialization phase of execution, i.e., the ones shown in the EXPLAIN
output and not the ones referred to by the =E2=80=9CSubplans Removed=E2=80= =9D
property.".

Any opinions?

The above sentence looks = good to me.


--
Thanks,
Tender Wang
--00000000000091493c06311319b4--