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.96) (envelope-from ) id 1vOIOg-001R4O-07 for pgsql-general@arkaria.postgresql.org; Wed, 26 Nov 2025 16:29:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vOIOe-000Wot-1H for pgsql-general@arkaria.postgresql.org; Wed, 26 Nov 2025 16:29:36 +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.96) (envelope-from ) id 1vOIOd-000Woj-34 for pgsql-general@lists.postgresql.org; Wed, 26 Nov 2025 16:29:36 +0000 Received: from mail-vk1-xa2a.google.com ([2607:f8b0:4864:20::a2a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vOIOb-001bNI-1l for pgsql-general@lists.postgresql.org; Wed, 26 Nov 2025 16:29:35 +0000 Received: by mail-vk1-xa2a.google.com with SMTP id 71dfb90a1353d-55b0d4b560aso724562e0c.0 for ; Wed, 26 Nov 2025 08:29:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764174573; x=1764779373; 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=6HIn4BgLOZoEtt8CnauWvfI142szWEcs2Ea0VhcmryI=; b=luYGUBlrGv1k0d9Y+COgvv110gXwo3c1ydiVOI8y88sME3NmcL6azXSBJxIbKqtDx2 1LlyR/cJJrVJnZtC7dwsyz7pbL64iBUrjHYeF6xZ1Wv2ZVjy2Soh48YkuBrGAgqJYndr i6u5UifIUDI0wR45Emt0/iLNb5aRIonTVOmPMpvR1cdydz2eR6zRTbDTJDXCjLUImaNp ccrTMWkq9D17eahCevyg6YCpTNNEfpuKodcrBtvLpWL9D09mlylWGQHPEYcVia1PsrYl CvvYLGzj2ORWEV8WwQ3y8X7QG3F12DuaPsBkbH2fFZG02sriA90gnyvhUDtS6Mdo1bS1 amxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764174573; x=1764779373; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=6HIn4BgLOZoEtt8CnauWvfI142szWEcs2Ea0VhcmryI=; b=XUvowzpw/TXWe8/zfZPfusVuc4/aQMa5XrJcmNmSHRr4B4O5Tc+O013Jyqq5IZOMH3 aD6OamCerN++v4hyqExMYU9BbBe9wg4CEa9pFysuJ94cyf6t3+X4uj1DQzreAQE1JS53 xmkCCXipihBil4lKPTz0Tr2VlBMybeCWvVg5ZaPZgz0mtroO7uuTxu1GE1TISLBp+5TX DEHmqK09adGWdEVP2bmZgktd68KtJ1fMzvySo9Y/kDfZzUkAdFCEu3v3pyLcX5OFG9Ar E5HlD6XDEMaLuZj9l10P5r+gGQ4LsEam4buz1UnBgG0LONAUAddUojIF53+ictlOqiMF vLiQ== X-Gm-Message-State: AOJu0YwUlwssGmYdPqTedb7jkPXvISYozxWDTQEGYj0q4zgFAebK8bMl W5EJ66kgcm7yhA8s+KjEFazkM4Pw0NA6qztoGjffwd1HJHcaXmEDrZlUy5sfq7ExkrjZGD6hXI6 +BHVKu/k+39QQ2ROb5wMRm308kjr/0bXt X-Gm-Gg: ASbGncuMxRLMtI+L6QF0AFtPWxKhiITPzwSc4Ry0sYv/vN04FXodKmoeeNiFhu2don8 KqIts3KJ/V/aA66cC7WPU/+XJBykIX9t1Hwmh9xd4miVKI1mVt4cFCO+PnQCDcoZxNiTV5lSzo3 LHcWlP4joqfohHcqgb+trC0COFLs7U7GroXq7MhxOipKt4J+GwCvqrsaTCUtSNjiS8XYH8wYamd CTEWgCj4NRxdapyXqPVsGSaRL9w/HfNUlWCy1o6TT1dpIPkI2h9qOk/k5br5EyaLCWvGnqCI7Ep BwguE/GMX4fNyIfv7K82Ih5HilJNrIDd6MwLdppkCtltGrYiK5P59vLr1GwN X-Google-Smtp-Source: AGHT+IGAMP5uXsIh998kIr7cwwdue+xq8yTLmD+7WjdYPHwTudr/azL4w9lwGEQpojSsl2Ww/vPvUJJG88+2qEpDzE8= X-Received: by 2002:a05:6102:c52:b0:57d:9305:63f0 with SMTP id ada2fe7eead31-5e1dcf3e21fmr7085362137.10.1764174573100; Wed, 26 Nov 2025 08:29:33 -0800 (PST) MIME-Version: 1.0 References: <60a4dc2711441931d29df7a43ba7447bbedb402f.camel@cybertec.at> In-Reply-To: <60a4dc2711441931d29df7a43ba7447bbedb402f.camel@cybertec.at> From: atma ram Date: Wed, 26 Nov 2025 21:59:22 +0530 X-Gm-Features: AWmQ_bl0ccuLf_eEdHtPl3t49WaOU1ov4kmB3fGoo5RPDpBVmqrnEpe0udLGQHc Message-ID: Subject: =?UTF-8?Q?Re=3A_Question_on_PostgreSQL_Table_Partitioning_=E2=80=93_Pe?= =?UTF-8?Q?rformance_of_Queries_That_Do_Not_Use_the_Partition_Key?= To: Laurenz Albe Cc: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000c06510064481e610" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000c06510064481e610 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Laurenz, Thank you for your reply. The table size is 1.6TB and not GB. My bad. The queries using primary key or partition key will be definitely improved. My question is 20 queries that do not use partition key and use only index. Since this is a critical OLTP system, even if there is a slight chance that those 20 queries will degrade performance, then we may not go with partition and find any alternative ways. Hence the question. We can do a POC and find out. But wanted to check if there are any existing benchmarking, explanations or details available before we do POC. Is it worth it? Thanks, Atma On Wed, Nov 26, 2025 at 9:05=E2=80=AFPM Laurenz Albe wrote: > On Wed, 2025-11-26 at 18:50 +0530, atma ram wrote: > > We have a table that is approximately 1.6 GB in size. Query performance > has started to degrade. > > Although we have multiple indexes, the large table size is still causin= g > performance issues. > > 1.6 GB is too small for partitioning. > > > We are planning to partition the table on the primary key. This is an > OLTP system, and there > > are around 100 queries that access this table. About 80 of these querie= s > use the primary key > > and will therefore benefit directly from the partition key once we > implement partitioning. > > If a table uses the primary key, I cannot see how it could cause > performance issues. > > I expect that these queries will become slightly *slower* if you partitio= n > the table, > because of the overhead of partition pruning. > > > However, the remaining 20 queries do not use the primary key; they rely > on other indexed columns. > > Our question is: after partitioning the table, and after creating the > necessary indexes on > > each partition, what happens to the performance of those 20 queries tha= t > do not use the partition key? > > =E2=80=93 Will their performance degrade? > > Very likely yes, though perhaps only slightly. > > > =E2=80=93 Will it remain the same as before partitioning? > > =E2=80=93 Is there any chance it will improve? > > That is unlikely, but possible, for example if the query can choose a > faster sequential > scan on some partitions, instead of a slower index scan on the whole tabl= e. > > > Is there any benchmarking, documentation, or reference material that ca= n > help demonstrate > > how partitioning will affect the performance of the 20 queries that do > not use the partition key? > > This information is critical for us before proceeding with the > partitioning strategy. > > The only good way to tell is to implement it on a test database and try i= t. > > But as I said initially, with a 1.6 GB table patritioning is pointless. > > Examine the performance bottleneck with EXPLAIN (ANALYZE, BUFFERS) and tr= y > to improve > your queries. > > Yours, > Laurenz Albe > --000000000000c06510064481e610 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi=C2=A0Laurenz,

Thank you for your=C2= =A0reply.

The table size is 1.6TB and not GB. My b= ad.

The queries using primary key or partition key= will be definitely=C2=A0improved. My question is 20 queries that do not us= e partition key and use only index. Since this is a critical OLTP system, e= ven if there is a slight chance that those 20 queries will degrade performa= nce, then we may not go with partition and find any alternative ways. Hence= the question.=C2=A0

We can do a POC and find out.= But wanted to check if there are any existing benchmarking, explanations o= r details available before we do POC. Is it worth it?

<= div>Thanks,
Atma

On Wed, Nov 26, 2025 = at 9:05=E2=80=AFPM Laurenz Albe <laurenz.albe@cybertec.at> wrote:
On Wed, 2025-11-26 at 18:50 +0530, atma ram wr= ote:
> We have a table that is approximately 1.6 GB in size. Query performanc= e has started to degrade.
> Although we have multiple indexes, the large table size is still causi= ng performance issues.

1.6 GB is too small for partitioning.

> We are planning to partition the table on the primary key. This is an = OLTP system, and there
> are around 100 queries that access this table. About 80 of these queri= es use the primary key
> and will therefore benefit directly from the partition key once we imp= lement partitioning.

If a table uses the primary key, I cannot see how it could cause performanc= e issues.

I expect that these queries will become slightly *slower* if you partition = the table,
because of the overhead of partition pruning.

> However, the remaining 20 queries do not use the primary key; they rel= y on other indexed columns.
> Our question is: after partitioning the table, and after creating the = necessary indexes on
> each partition, what happens to the performance of those 20 queries th= at do not use the partition key?
> =E2=80=93 Will their performance degrade?

Very likely yes, though perhaps only slightly.

> =E2=80=93 Will it remain the same as before partitioning?
> =E2=80=93 Is there any chance it will improve?

That is unlikely, but possible, for example if the query can choose a faste= r sequential
scan on some partitions, instead of a slower index scan on the whole table.=

> Is there any benchmarking, documentation, or reference material that c= an help demonstrate
> how partitioning will affect the performance of the 20 queries that do= not use the partition key?
> This information is critical for us before proceeding with the partiti= oning strategy.

The only good way to tell is to implement it on a test database and try it.=

But as I said initially, with a 1.6 GB table patritioning is pointless.

Examine the performance bottleneck with EXPLAIN (ANALYZE, BUFFERS) and try = to improve
your queries.

Yours,
Laurenz Albe
--000000000000c06510064481e610--