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 1vmDce-008xSG-1q for pgsql-general@arkaria.postgresql.org; Sat, 31 Jan 2026 16:14:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vmDcc-008Yg8-1b for pgsql-general@arkaria.postgresql.org; Sat, 31 Jan 2026 16:14:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vmDcb-008Yg0-2U for pgsql-general@lists.postgresql.org; Sat, 31 Jan 2026 16:14:54 +0000 Received: from fhigh-a6-smtp.messagingengine.com ([103.168.172.157]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vmDcZ-00000000Nu5-2a9d for pgsql-general@lists.postgresql.org; Sat, 31 Jan 2026 16:14:54 +0000 Received: from phl-compute-12.internal (phl-compute-12.internal [10.202.2.52]) by mailfhigh.phl.internal (Postfix) with ESMTP id 4C4141400048; Sat, 31 Jan 2026 11:14:50 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Sat, 31 Jan 2026 11:14:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1769876090; x=1769962490; bh=xz1tOqtKOaBCnfUrTQDULPM0Qil3mz8xfxwxnz9Htew=; b= BkDSV5RFrZPp4pLFShPPTh4Z6sJCOx7ZJVOvv6iuPAvtM4LWCFqGIyzmzBeXe0JG BP0f5JDLk0B1/jD0wKhyCo/ZtjmU4dWkBI2p60DGUZ1sMObiiiv15GVZD4dTnFST Xs/T59yQ4+w/8WbZqaUqrJQm5ZNHDGmkIVAC/tAsqh0+Ulm0bK7U4Y+1v2vSr8xZ EEwX1/CLOZ+kukQyRjWeMAZFIiOYlihgDXsy1yC2aWWrwnWGHpl13+YNr33DwVE6 5SQSXthAdhdESNX8ZgS3A1n3pNeXRmN8vIDksibrEPJaRY8N0CkgPAPTY7mTBjlu htvgUC7GGhqohttGCqdiuA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1769876090; x=1769962490; bh=x z1tOqtKOaBCnfUrTQDULPM0Qil3mz8xfxwxnz9Htew=; b=WokTtsbJMFZv1HKO/ GgtZGTac5dHZ4rAknJqJS6o3Oqwgh6NyJMT2SVo53fPSsRghOhV5cWPKcs73LLCC dm90TeghKEBDGeRnEa1Hx7gLDrD8URCttuXFTKvxsi1f3O+UwD8WvtVjQRNC8Niy PJJWpSP47TdhmiACSOoM0XZnlo/EPnu4H8BO5PpsPYzQLDh/rZLSCjDTuLW3g5c1 5JuzbUv0qFXqi5OqIMZWFxyOlsCzzXtJ5jeUZSeYv7YSqAmLDFmb8ri8vv9Ko+h9 wffysZhlKbF8WCrPfimyahdDYTpOvKIVQLGeOYkWn1Lactxlx/yYAipNxdHR5zK3 dHYOg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddujedvfeejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucenucfjughrpefkffggfgfuvfhfhfgjtgfgsehtkeertd dtvdejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgr vhgvrhesrghklhgrvhgvrhdrtghomheqnecuggftrfgrthhtvghrnhepffelgeeifefgve duhedthfekuedtffejveegffegjeevtdehgfduieetfeehjeehnecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrh esrghklhgrvhgvrhdrtghomhdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphho uhhtpdhrtghpthhtoheplhgvrghrnhgvrhgurghtrggsrghsvgelleesghhmrghilhdrtg homhdprhgtphhtthhopehpghhsqhhlqdhgvghnvghrrghlsehlihhsthhsrdhpohhsthhg rhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 31 Jan 2026 11:14:49 -0500 (EST) Message-ID: Date: Sat, 31 Jan 2026 08:14:48 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Top -N Query performance issue and high CPU usage To: yudhi s , pgsql-general References: Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 1/31/26 05:30, yudhi s wrote: > Hello Experts, > This query is going to be called in the first page of an UI screen and > is supposed to show the latest 1000 rows based on a certain transaction > date. This query is supposed to allow thousands of users to hit this > same query at the first landing page at the same time. Its postgres > version 17.  The instance has 2-VCPU and 16GB RAM. 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. 2) You will need to provide the schema definitions for the tables involved. 4)And based on the CPU core and memory , is there any calculation by using which , we can say that this machine can support a maximum N number of concurrent queries of such type beyond which we need more cpu cores machines? You already have the beginnings of a chart: 1 session 2-3 secs 10-15 sessions 50-60% usage 40-50 sessions 90% usage > > Regards > Yudhi -- Adrian Klaver adrian.klaver@aklaver.com