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 1vmGw5-009jmD-0Q for pgsql-general@arkaria.postgresql.org; Sat, 31 Jan 2026 19:47:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vmGw3-008z7W-0n for pgsql-general@arkaria.postgresql.org; Sat, 31 Jan 2026 19:47:12 +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 1vmGw2-008z7O-2y for pgsql-general@lists.postgresql.org; Sat, 31 Jan 2026 19:47:11 +0000 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vmGw1-000NRO-0h for pgsql-general@lists.postgresql.org; Sat, 31 Jan 2026 19:47:10 +0000 Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-65808d08423so4825447a12.1 for ; Sat, 31 Jan 2026 11:47:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1769888828; cv=none; d=google.com; s=arc-20240605; b=jPEaIDMW3hV2zhK5vxp1p4CfDwmOxVWiK90yzvutqJRdRBmfk4o34GArpOqggGV3Js jvmt5FV/O72YG21Eaxu3Z2ICE0/h3gNrN2U6evejSvzRBBwSJPPCfYTzGPVRplIkCNhv pQ0nOvRYZ7m3bYW9KUzDAl60113Uh0TpG8evvUhMPQkk5VL+biv2xk7DAFRLzsH6hRRO KgUGbn8Thu2rv3I9IGuZ4vnDEmQ0xmk1Ooxd9uMD1Ivg4p//FJ9XC7bCqVZe0dRHdJiK a8cWZPf9sG6cLmxP4LxUarPYBKEncC3jXZs+3FGDSqW07A7Ochr5PJPA/p4wqKwCLyxS F28Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=vPg/fq5EFUj48x1NeTjg4c9j4Mi5KmPmg3lO/aq1if0=; fh=RFbrF0mTQjBlqpfYYdXHfF5Pse4kYeQx4U0mhRMjtNI=; b=bT9SOE8GxlMhcNN5zFnps2JjWwmAbgNrjQ2PRKHKvQLGgOkcLLCKZ6nwWEHySzG2OY aCWbLmX0mFHZBoa0pvkde0jxz8nKohJYAZSv0ew+Oo3xBL/zErY7X8Yf6XxikrSmUuG3 r32oF20hxQx3dsgzjxKhdaBe1XcBWZiWsOVfEFaaPmPPLeDzS9AjZL+8hft5KmB17xJ8 TvX3VghR3Rvk0dx+SJmZE9QT52UhhvU3ye9x6ORv8SgGOtTqBILur1X69yVFU+IMKzZM ekAexDJXjRH8XHilu0qj3uveqy14GVGel2Qe5iQHA4afhj++wddEjLxSSq3H3T41n63i IXjg==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769888828; x=1770493628; 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=vPg/fq5EFUj48x1NeTjg4c9j4Mi5KmPmg3lO/aq1if0=; b=H/Y1o90nl3AaVgt0MyuntTIHPbEHpjFnjGnKMNRcgP32Zj0SwRkhC1VdCIg7mbyloJ W7WGE9mspglOeH/Yv7wlqWKqwWZFKfc5H2dp5TxUf6HnWANs6m8a1Zz0JDvbj1pdgbAy Cja1BW1FVFuZyhRw3SBZAET/GTCzcGYzXb2x2exHSjmo1Ps1dSLGAJveJCAWpq7FrryO Z5PrT2UguludPGLh+2ydNWZ6e2/wfSQXXzWkqa8vbjqzjaMJARIGSnc6VVkH6+M0XbRZ R/JW9Aei7oIl8XM1M1W0SX3Pj9Do66noyPKbqbCHeu3mwlIkuYczu5EnNXoyCCU11apA kD6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769888828; x=1770493628; 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=vPg/fq5EFUj48x1NeTjg4c9j4Mi5KmPmg3lO/aq1if0=; b=bVhTQbMdyKng813hB8cIPPcofQO4Ey3qKOPhWzjsDbYvTF+Hc4ZdjDrJNcBkZ0Qz9a KZVkx+PGD94CodfLCp6UHDJkV8pLKBOm+VuZAwxOGBe1ALsaWmHr3Twk74AqpPPlnAEF 75n8V25DkMMfm0i+XkvR+M5uW2YOElAsSVayqZ1TIflwP/V3JBhZSZ6TjP20sYzEVjGO k7bmqHvMK159Zj2akm13vAPyAEZGu/AFv6Hr6rdB1xGSsFjNbcKdgfwC5/dfQ+KU2nAb VArByziMWVIipNOMsoU5lx41Ber6ExwKJr/7zXVC8JKKFk05sfBplx/gc6Q0pG2ZkBNZ EC3w== X-Gm-Message-State: AOJu0YxRDdZqzz8GeMz3TkOduicBRaTiOU7/zbFooKO5ZeLF5/jrx0Ek C+2V3chtHKK/05dL7x3pinkScWaxCE4VzmZ81hCwiVzRk40Bx/GLj5F/rShR0Bfv1hbxWkTcbtS YO/S21YRWnbDQAC/oXsuFiTEdj+eXPVRZ8A== X-Gm-Gg: AZuq6aIZ/syWtXh0YJpxEIItxF77Y6yeuDXeCeunEmqZkriueZLfWvg5ZUwUKANHIpf x/i9agRno0b0cObH86EkwWXTMVDYlVa5zAIWG+O6VxmL70aypexjQePjXg63HvCssBu8DiZgoui dtOuDy3PV6sdr6S0YTsUApoF7JQREbtob1EmbisldqVxlYNAf4YiVgC9j0AIIpDdrrlDmC0sPbi METSIy7py8rQFt73lXDArP6E8iyumefmQfXVrvSS6FutzHbyq8BhCjn1cj94/h2FA8G9Wr91pQ3 vgXf6blQMaxiBKTgDvpWtqKY X-Received: by 2002:a05:6402:42c5:b0:658:d18e:e6 with SMTP id 4fb4d7f45d1cf-658de55263dmr3888924a12.11.1769888828067; Sat, 31 Jan 2026 11:47:08 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: yudhi s Date: Sun, 1 Feb 2026 01:16:56 +0530 X-Gm-Features: AZwV_QgXRy8fFi6Z2Hwn4RSXp6ggLp8o4KDk4UbW6SHflKk0dAwC-fmQ6F1rHOM Message-ID: Subject: Re: Top -N Query performance issue and high CPU usage To: Adrian Klaver Cc: pgsql-general Content-Type: multipart/alternative; boundary="000000000000e3936d0649b45a7b" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000e3936d0649b45a7b Content-Type: text/plain; charset="UTF-8" Thank you. > > 1) Without even looking at the plan I'm going to say 2-VCPU and 16GB RAM > and is insufficient resources for what you want to do. > > Can you please explain a bit in detail, how much minimum VCPU and RAM will be enough resources to suffice this requirement? and you normally do that calculation? > 2) You will need to provide the schema definitions for the tables involved. > > Do you mean table DDL or just the index definitions on the tables should help? Also i was trying to understand , by just looking into the "explain analyze" output, is there any way we can tie the specific step in the plan , which is the major contributor of the cpu resources? Such that we can then try to fix that part rather than looking throughout the query as its big query? And if any suggestion to improve the TOP-N queries where the base table may have many rows in it. --000000000000e3936d0649b45a7b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thank you.=C2=A0

1) Without even looking at the plan I'm going to say 2-VCPU and 16GB RA= M
and is insufficient resources for what you want to do.


Can you please explain a bit in detail= , how much minimum VCPU and RAM will be enough resources to suffice this re= quirement? and you normally do that calculation?
=C2=A0
2) You will need to provide the schema definitions for the tables involved.=

Do you mean table DDL or just the index definitio= ns=C2=A0on the tables should help?

Also i was tryi= ng to understand , by just looking into the "explain analyze" out= put, is there any way we can tie the specific step in the plan , which is t= he major contributor of the cpu resources? Such that we can then try to fix= that part rather than looking throughout the query as its big query?=C2=A0= =C2=A0

And if any suggestion to improve the TOP-N = queries where the base table may have many rows in it.
--000000000000e3936d0649b45a7b--