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 1tY89C-004Gha-Hp for pgsql-performance@arkaria.postgresql.org; Wed, 15 Jan 2025 18:29:46 +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 1tY89A-00FEl0-Vk for pgsql-performance@arkaria.postgresql.org; Wed, 15 Jan 2025 18:29:45 +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 1tY89A-00FEkr-EW for pgsql-performance@lists.postgresql.org; Wed, 15 Jan 2025 18:29:44 +0000 Received: from mail-oa1-x2a.google.com ([2001:4860:4864:20::2a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tY899-000ZrX-1Q for pgsql-performance@lists.postgresql.org; Wed, 15 Jan 2025 18:29:43 +0000 Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-29fe83208a4so80391fac.0 for ; Wed, 15 Jan 2025 10:29:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736965782; x=1737570582; darn=lists.postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=nDAUvS2QE6kbHc5xuyi+dEDsmBT6fCx58qmYxGkIhQU=; b=fUgggk7dbjZl7/OxjOPbgQmrCdeU9cexbD4Seygofw1wBIkHKju1Pe+vrJG8xgYSFn BjnJOjRca+nTJlCG7TMjsX2n0Lv9dsDkte5qyh3OoyI5xfcNXoFCQ8QvSHWxixcJmhUB z/RfHu2tKNBW17yabvA+8VuC64B/EqGfS7f3QicMVRaeciHynNSnhnR1/tf3HeZlkKFs xeakvpap6Zog/YnSBQWpfyXJmQ3ebeWuxYcRdSJSYY1IvxRiR5NPxeEa75YkIqUbt8/q RV+zacZ4hfjdogoo6qjUJoH+AG6r76qJT2zCvCTJNlmrkA6+3qax51djhEcq7hTF8hjV UZOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736965782; x=1737570582; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=nDAUvS2QE6kbHc5xuyi+dEDsmBT6fCx58qmYxGkIhQU=; b=DU0whDglU58UKKRTbwLpshik4gJx8gd9KfjC6+P7k89ftXUuTprP7muHPchBTLaAAW T2XLClg1MfUwM4s3iboaqVFx9Fp/CGzrVwmNUpcJMp/94XIRwQNCnMD/EoEhk+7urH/z iUylL1yKopZdnfTGQavcQWS8yIXbByiDD6jZcfFhtQg5HOYex5WeOWblMVl/aOb8ErqX i/LiKNLN5Ve3dsTWKbFEMPMr0cI3CShQjzkkI+mPH764mE64rXPMveRQ+hMYADHqsLAd daOcA+S3Ng3PIaScpJyVQJG9Fricxyu/BjV+lekLBKQWNkbnmE/Ii/FvTMFGjzBbpkG+ 94ow== X-Gm-Message-State: AOJu0Yy2GGQWTVxDIK07B1OYzALq1ahjp4XhYgvbFLAwNQHHptZ6M1Lt yS79pMfClgB14PCSdhmc9U8RyaGmS8zlVCgXgkF/bNJxxfkZX1CLvL3gILatk7erdIBpoJAnExD bL4YzdCzyBLo84vSNkMsEdraXUy8HVQ== X-Gm-Gg: ASbGncuvX9jevmnwZ/Z7qR/NYMcpVc71pqVbAvNGhfQ0u1sePW6zWjcxfRINAOcxVv/ Lc/xJId4F7jmb13a5Q2HmuShyLnMoyCsB8GvUiWhu X-Google-Smtp-Source: AGHT+IGDl5+PJLWGSWDBvyZ95buMxLBjHqtV6dcvMY4DMrRhsqLgnfWXosTLdWy/VNPZuVqui53b8wfUIl0E6jzZ6ws= X-Received: by 2002:a05:6870:d622:b0:2a7:5ce8:820f with SMTP id 586e51a60fabf-2b186aec0b8mr2646611fac.9.1736965781528; Wed, 15 Jan 2025 10:29:41 -0800 (PST) MIME-Version: 1.0 From: bruno vieira da silva Date: Wed, 15 Jan 2025 13:29:30 -0500 X-Gm-Features: AbW1kvZRzsvAQe2qA3h1buQI5suCYG9t8iNSYYcXLmx6cTUU2XW-lKldSnQBX9o Message-ID: Subject: Query planning read a large amount of buffers for partitioned tables To: pgsql-performance@lists.postgresql.org Content-Type: multipart/alternative; boundary="00000000000065281d062bc2dc3d" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000065281d062bc2dc3d Content-Type: text/plain; charset="UTF-8" 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 read 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 --00000000000065281d062bc2dc3d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello All.=C2=A0

On pg 17 no= w we have better visibility on the I/O required during query planning.=C2= =A0
so, as part of an ongoing design work for table partitioning = I was analyzing the performance implications=C2=A0of having more or less pa= rtitions.
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 h= ave a caching mechanism as subsequent similar queries require only a fracti= on of buffers read during query planning.
However, this "cac= hing" seems to be per session as if I end the client session and I rec= onnect the same query execution will require again to read 12k buffer for q= uery planning.

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

=
Thanks
--
Bruno Vieira da Silva
--00000000000065281d062bc2dc3d--