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 1twdWE-00GCL8-3W for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Mar 2025 08:50:50 +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 1twdWC-00GYVZ-Qd for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Mar 2025 08:50:48 +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 1twdWC-00GYVR-HJ for pgsql-hackers@lists.postgresql.org; Mon, 24 Mar 2025 08:50:48 +0000 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1twdW9-000q3I-2k for pgsql-hackers@lists.postgresql.org; Mon, 24 Mar 2025 08:50:47 +0000 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-54acc04516fso3707678e87.0 for ; Mon, 24 Mar 2025 01:50:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742806245; x=1743411045; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Iyn/6q/NOu+xS/QJ0NYW/NYhbM0CUjtIPohxaBS/mLc=; b=ED0xB4W7+WbK05HLPryvpOxnl09rDRPUzfsbsJwmyFU/YdDza0STfFbhRCvBnpwKd8 bUtElx86as+LnTWug1/zKXmOVNF9I4q5DV7eU6da5wllgnYpop6pWPZLWLsQyXLvM8nI PMvOI2TQQRS1w+1VFPqeOkaceELIJSSvrH8WLBMa227vYU18KqLe3ogsa2+EFqxv8DNg 58v5DCH850s2PeoBNFXG8/PTZNEAoz4EHMJBhCKMNS8vF2VLg4zaCHSS4WU5B6enjj6K Yhi8KC0xTcqDCbSN8g2Hbcf1THPfnxmDEVrBhQUFa66eJn4DTwLUlwV49cGxjzk/KPHi YKjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742806245; x=1743411045; h=content-transfer-encoding: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=Iyn/6q/NOu+xS/QJ0NYW/NYhbM0CUjtIPohxaBS/mLc=; b=j+ZPpuVqdYLO8Ksxof9GaN1lAaNMiCyw5hrh1k7A+ZqBeukgvm7UXIVVDnBBNqAOxf LrjkAfAxFVNdaexYtirX9hKqELu2hs90XXTvhw3L77FtNJC7sOkSPoOL0EZ7tV0UA3Nd 5X3AZUX4iaSUuCRJRI1nO2XfaHIPhsFodCcIXuVX11MOzBylqP9xt2FMyioLbPXHORc9 +s28vBOeNIBPIS++p+yxAKAp8N3Mijli1zz29mXE3ZNe6XOXRYqX6Y76TvWbe9ndk4Z3 mPk67v1ynUNl1F63nBJPntHqfHfGEZmzy0TMojXwcnLhE3YXM+pHfpNVbeKgSYaZzMPS Mi+w== X-Gm-Message-State: AOJu0Yx4BqSweNUioeyuKNHTT9z4SabCNf1c36Pvf3cSQhjOXPlQNHeb w1rdK2qG/fbBYsgGhgBoztHAj6uuK9FYgqokgBj8h2HR/SEC3jFYPqd88RxNKM2R3yAepe1tzIO xUoxpNYouNKpR69tdtM+844c5E0I= X-Gm-Gg: ASbGnct9PwrynTfSTar0hkyiacSdoJWzPAsbkRZUffCZN9W2yGnS6B7inh2H8GnaxsN KxtFVh9Y+ChgaCfGPibtOEmQWcQV/86JAi+TNSHL9FfHDPuyPk1xHxi7OPdNdI9Llty03N2JjpL Rt27JVL1s/tsvdICf/m7qIs3NAlyJvuFU1/nPXhhLwXiFD5MXSbERDl0OtBDQKK4msPoYRYw== X-Google-Smtp-Source: AGHT+IECtUfod3dZAolciREWjv6uxJSlsAyO41aAXKDtZs9Mg5pM76P5OATOMqvBqWIMIlJMMG4UjCyhNXX7EUKDlU8= X-Received: by 2002:a05:6512:31c7:b0:545:e2e:843a with SMTP id 2adb3069b0e04-54ad64ef1e4mr3629528e87.38.1742806244684; Mon, 24 Mar 2025 01:50:44 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: David Rowley Date: Mon, 24 Mar 2025 21:50:32 +1300 X-Gm-Features: AQ5f1JpD7PN1p8CD7DRw58-YTexJf10zyKw1hKw7sNHBplFWsVyiecMQX4G4w2o Message-ID: Subject: Re: Add mention in docs about locking all partitions for generic plans To: Tender Wang Cc: PostgreSQL Developers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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 thoug= h it is pruned during initial partition pruning. > This seems to contradict what you said. "This is no longer true in maste= r" . 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. 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? > [1] https://postgr.es/m/01020195b987abd3-a008b77d-8c63-4931-80a4-be36a351= c8b2-000000@eu-west-1.amazonses.com David