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 1t8oFB-0063xr-16 for pgsql-general@arkaria.postgresql.org; Wed, 06 Nov 2024 22:11:16 +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 1t8oF8-009fAG-C3 for pgsql-general@arkaria.postgresql.org; Wed, 06 Nov 2024 22:11:14 +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 1t8oF8-009fA8-1c for pgsql-general@lists.postgresql.org; Wed, 06 Nov 2024 22:11:14 +0000 Received: from mail-oa1-x31.google.com ([2001:4860:4864:20::31]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t8oF6-000XD3-3Q for pgsql-general@lists.postgresql.org; Wed, 06 Nov 2024 22:11:13 +0000 Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-28c654c9e79so777302fac.0 for ; Wed, 06 Nov 2024 14:11:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730931071; x=1731535871; 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=ipvvt5UEu6CHH/wqqoLS/KqwFTHSKs6t35k6OI5t5D4=; b=h5XUBUhs7UhjnOsqY7OzxSLiX08AH/Gq3vuLJGT22sygRSm43py6t8LfK6/ctpqQTZ PlxGuPj0xIu36bCCoCBIlG3Y62T6FhwHGVlNAvCY9RfRFWDDFTKLtCLgBRC35dq9t8pW ZAI9RI5l7plagb53WWSiX8SxV+4RKmsCqNs/VjFB8G/lZ8b1HF9NhxTRlS05MkLBpEof rwE3DUMp+XNz85EOvUJD9TZhK1vkLoXb0YYos/rq4s0/T/nOr3Z4mMWRntEzypBo6h8u o0vi8D2V0xTWk5mhimaBMnlJbCPm4gbA3AAeP1LPb9ODw9SgbUninX9mlXgBwqiJNu70 okJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730931071; x=1731535871; 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=ipvvt5UEu6CHH/wqqoLS/KqwFTHSKs6t35k6OI5t5D4=; b=cZFSXUqTItoYZABPhynhB3Wvc7xxA8YIeTQsOY9LvqpSteBNVlVj4AoEpO+7Q9DE2w wJCVPzZip3zhZLtkqaYJVg7z0LTzLvsGPGj8QJlrtSZwEBvQGcIc/yJ5g0OX9zHLohZp i5joK3g3iiwVUbPFAu9JTUqH0sfUH/UEcIaeoPzeWYrBKf0j/QeewKvkAWfic0I55Ez0 24t31vX+/ZCXjPkNkOCo9titbjUkAU6lAAxFpN/hrusZsVYcei3GT5w3pNBi7Zr4M0ip JRZmSdz2ZMzRvv3ADXwI5BlmbbmhcouvRbE6eH/YWAq1pmxffRU4vyCkgK6GMdXC2g49 /+/Q== X-Gm-Message-State: AOJu0YyeIoQyKeORQPc2Jmg4pxLlGX9HBPBf9mi+88HEILbOeLW/jZ/d bqBa+YY1dG2urv1zDhnrtmYLAUVFUnXtU5z2yBoYkZCbYlbmKDaEauXvqtC6o/dUj2/pXfRBZ1j 16PKgmblu/saIG1e+rBM7HPClK/0= X-Google-Smtp-Source: AGHT+IGBvh6PGtzuk+H6b/n1Yl0mPsj28DlNYLwDNlpniD27Tj4ZgZaweocrPmS9ONBSygpQOZyjnCBHcWCIRiXz23M= X-Received: by 2002:a05:6871:4398:b0:278:15b:8ee0 with SMTP id 586e51a60fabf-29543002737mr528502fac.7.1730931071017; Wed, 06 Nov 2024 14:11:11 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: David Mullineux Date: Wed, 6 Nov 2024 22:11:00 +0000 Message-ID: Subject: Re: Performance Issue with Hash Partition Query Execution in PostgreSQL 16 To: Ramakrishna m Cc: pgsql-general , ravisql09@gmail.com Content-Type: multipart/alternative; boundary="0000000000009e6ca7062645cb04" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000009e6ca7062645cb04 Content-Type: text/plain; charset="UTF-8" It might be worth eliminating the use of cached plans here. Is your app using prepared statements at all? Point is that if the optimizer sees the same prepared query , 5 times, the it locks the plan that it found at that time. This is a good trade off as it avoids costly planning-time for repetitive queries. But if you are manually querying, the a custom plan will be generated anew. A quick analyze of the table should reset the stats and invalidate any cached plans. This may not be your problem just worth eliminating it from the list of potential causes. On Wed, 6 Nov 2024, 17:14 Ramakrishna m, wrote: > Hi Team, > > One of the queries, which retrieves a single record from a table with 16 > hash partitions, is taking more than 10 seconds to execute. In contrast, > when we run the same query manually, it completes within milliseconds. This > issue is causing exhaustion of the application pools. Do we have any bugs > in postgrs16 hash partitions? Please find the attached log, table, and > execution plan. > > size of the each partitions : 300GB > Index Size : 12GB > > Postgres Version : 16.x > Shared Buffers : 75 GB > Effective_cache : 175 GB > Work _mem : 4MB > Max_connections : 3000 > > OS : Ubuntu 22.04 > Ram : 384 GB > CPU : 64 > > Please let us know if you need any further information or if there are > additional details required. > > > Regards, > Ram. > --0000000000009e6ca7062645cb04 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
It might be worth eliminating the use of cached plans her= e. Is your app using prepared statements at all?=C2=A0=C2=A0
Point is that if the optimizer sees the same prepared query , 5 times, t= he=C2=A0 it locks the plan that it found at that time. This is a good trade= off as it avoids costly planning-time for repetitive queries. But if you a= re manually querying, the=C2=A0 a custom plan will be generated=C2=A0 anew.=
A quick analyze of the table should reset the stats= and invalidate any cached plans.
This may not be yo= ur problem=C2=A0 just worth eliminating it from the list of potential cause= s.

On Wed, 6 Nov 2024, 17:14 Ramakrishna m, <ram.pgdb@gmail.com> wrote:
Hi Team,
<= div>

One of the queries, which retrieves a single record from a table wit= h 16 hash partitions, is taking more than 10 seconds to execute. In contras= t, when we run the same query manually, it completes within milliseconds. T= his issue is causing exhaustion of the application pools.=C2=A0Do we have a= ny bugs in postgrs16 hash partitions? Please find the attached log, table, = and execution plan.=C2=A0

size of th= e each partitions : 300GB=C2=A0
Index Size : 12GB

Postgres Version : 16.x
Shared Buffers : 75 GB
Effective_cache :=C2=A0 175= GB
Work _mem : 4MB
Max_connections= : 3000

OS=C2=A0 :=C2=A0Ubuntu 22.04
Ram : 384 GB
CPU : 64

Please let us know if you need any further informati= on or if there are additional details required.=C2=A0=C2=A0


<= /div>
Regards,
Ram.
--0000000000009e6ca7062645cb04--