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 1tY8C1-004Hi4-7I for pgsql-performance@arkaria.postgresql.org; Wed, 15 Jan 2025 18:32:41 +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 1tY8Bz-00FIRB-TD for pgsql-performance@arkaria.postgresql.org; Wed, 15 Jan 2025 18:32:40 +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 1tY8Bz-00FIQM-JA for pgsql-performance@lists.postgresql.org; Wed, 15 Jan 2025 18:32:40 +0000 Received: from mail-oa1-x32.google.com ([2001:4860:4864:20::32]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tY8By-000Zss-3C for pgsql-performance@lists.postgresql.org; Wed, 15 Jan 2025 18:32:39 +0000 Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-29e70c9dc72so70152fac.0 for ; Wed, 15 Jan 2025 10:32:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736965958; x=1737570758; darn=lists.postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=qBuweegcPsIcny2xM/0+v8737Yl1jSQqjKsF5RuRnX4=; b=IOY35+1VkwdCyHKZn/uu0Nz2WVRdAdNtP+iPrHRnX3IvcR4Lqwz/noGBh8prQGHcwy hOkV2Ac1qH+vxtHa922mWoEMg5Y/cMg+OcSTmAf9WC7LjfyAWWJap3QoGTGENPdPjy+/ vEA/HaDsxL4f+RHQVLhv4Rrih9x+A1YuRPwzagmv6uehxIqudO6zg+fmd6wtpN2reYuP 3JrIh0epm1/uV+WaC+vERlqaiFG1zXI8ui4nRq3bZFSKWmAZXFnZ1oeRG1eDjTv8ZJwK pGU/d4HFP9aC5pVqN2JvT3fgX/ryBpFkZpA4meA5B6pBqBPLr2CKyLuD025DTJGYRg0g +njw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736965958; x=1737570758; h=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=qBuweegcPsIcny2xM/0+v8737Yl1jSQqjKsF5RuRnX4=; b=By2OuMtwzPLOBC0j3jpJ4dfrUH7/D/0e6q8mSb3DkFOPhhpMJBmlgoSH1OMmrmJMEc shF6lfBoCJucN7m/0vnEcpxsXVU+L/XrsWUT0ehU9aLqIma6xZASKi+4RSMYOQc6nez7 QAxRm6EUg+9NZzN3/JDnC8EJMctdcXN/j54aSmuoRobWS8FjWPUaF/pTlTwjxuyA2RJj aXtXt8xVixaELLhfRmU5vPg4ucN9ftyM+qiZh/mOpXqpunenZcs9QBRxXsdP1bK4bJsc SyQSDGwXoJ6tHOKsWCZAf2cmYCVA20kNM9lT9Iswa5RTa2P5hPeRC5QuO5g6U8LWUD4N AXgQ== X-Gm-Message-State: AOJu0YzUHbMCpkCUuw341fg3RbniSLJyaBQr7EWklpDWB48d7QgmCIk4 mFA2ixhdg4yJ6PVV65AgIq9R+8YkpJm3CPYrSF/SOO1DmFXN7Cu3jl7Gq9CgKjtq+P5CXp0Jg5U 8fnnmCNrfWc1PjTmuChcNRjAJQEXDgbq+ X-Gm-Gg: ASbGncsJd8WSg+n4xrbdU2tVdeVzXJxda/SZ9Y3w6aTBq+PD8ZVFbcV5BCq37AGca01 7+E6dGtseg95Hul37ZiTw4n8iLn3zgjwhDC9v8wXk X-Google-Smtp-Source: AGHT+IGbYYzRcHceCpnwOGzdBatM2gJWzrBTuPrphUjBj+EOUT4/zVyiCDbCJLPTYAq9Yd7wEpTmi/5hZK4aptBjrwI= X-Received: by 2002:a05:6870:e2cf:b0:29e:18cc:276f with SMTP id 586e51a60fabf-2aa066e09b0mr16330019fac.11.1736965957923; Wed, 15 Jan 2025 10:32:37 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: bruno vieira da silva Date: Wed, 15 Jan 2025 13:32:27 -0500 X-Gm-Features: AbW1kvYdLJ2vOkrEvIpBM9_9d43ixU273u21pnrreGI22sB4AvNbAbenpoQEQ2k Message-ID: Subject: Re: Query planning read a large amount of buffers for partitioned tables To: pgsql-performance@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000e8bbea062bc2e6dd" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000e8bbea062bc2e6dd Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable correction: Is there a way to have *visibility* on its usage? thanks On Wed, Jan 15, 2025 at 1:29=E2=80=AFPM bruno vieira da silva wrote: > Hello All. > > On pg 17 now we have better visibility on the I/O required during query > planning. > so, as part of an ongoing design work for table partitioning I was > analyzing the performance implications of having more or less partitions. > In one of my tests of a table with 200 partitions using explain showed a > large amount of buffers read during planning. around 12k buffers. > > I observed that query planning seems to have a caching mechanism as > subsequent similar queries require only a fraction of buffers read during > query planning. > However, this "caching" seems to be per session as if I end the client > session and I reconnect the same query execution will require again to re= ad > 12k buffer for query planning. > > Does pg have any mechanism to mitigate this issue ( new sessions need to > read a large amount of buffers for query planning) ? or should I mitigate > this issue by the use of connection pooling. > How is this caching done? Is there a way to have viability on its usage? > Where is it stored? > > Thanks > -- > Bruno Vieira da Silva > --=20 Bruno Vieira da Silva --000000000000e8bbea062bc2e6dd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
correction: Is there a way to have visibility on it= s usage?

thanks

On Wed, Jan 1= 5, 2025 at 1:29=E2=80=AFPM bruno vieira da silva <brunogiovs@gmail.com> wrote:
Hello All.=C2= =A0

On pg 17 now we have better visibility on the = I/O required during query planning.=C2=A0
so, as part of an ongoi= ng design work for table partitioning I was analyzing the performance impli= cations=C2=A0of having more or less partitions.
In one of my test= s of a table with 200 partitions using explain showed a large amount of buf= fers read during planning. around 12k buffers.

I o= bserved that query planning seems to have a caching mechanism as subsequent= similar queries require only a fraction of buffers read during query plann= ing.
However, this "caching" seems to be per session as= if I end the client session and I reconnect the same query execution will = require again to read 12k buffer for query planning.

Does pg have any mechanism=C2=A0to mitigate this issue ( new sessions ne= ed to read=C2=A0a large amount of buffers for query planning) ? or should I= mitigate this issue by the use=C2=A0of connection pooling.=C2=A0
How is this caching done? Is there a way to have viability=C2=A0on its usa= ge? Where is it stored?

Thanks
--
Bruno Vieira da Silva


--
Bruno Vieira da Silva
--000000000000e8bbea062bc2e6dd--