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 1vmfQs-00F5Qk-02 for pgsql-general@arkaria.postgresql.org; Sun, 01 Feb 2026 21:56: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 1vmfQo-00AX6k-2m for pgsql-general@arkaria.postgresql.org; Sun, 01 Feb 2026 21:56:35 +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 1vmfQo-00AX6c-1W for pgsql-general@lists.postgresql.org; Sun, 01 Feb 2026 21:56:35 +0000 Received: from mail-oi1-x22f.google.com ([2607:f8b0:4864:20::22f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vmfQn-000000005d1-2Tk4 for pgsql-general@lists.postgresql.org; Sun, 01 Feb 2026 21:56:34 +0000 Received: by mail-oi1-x22f.google.com with SMTP id 5614622812f47-45c93313721so2585519b6e.2 for ; Sun, 01 Feb 2026 13:56:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1769982992; cv=none; d=google.com; s=arc-20240605; b=TxMjicf7iPGkn2YN+QaqjaQMGWeDLS9zE14qxcD9NH/6GOVx/hXjG5i7s/NNNvCKTa QZ9sh9R7olUPFKJLzkVQ2fFJhl5TWSM/2sjTlWBaR60SGWwTj9hjUu9z69mIMMCGgk9C zDrncJsVArzBbXDxo7XWGRiWGugz4JJazH74jZV4rAPSs/KI3hLAOVxAcBEFZFBsTznC +3ThEcMM/VPCognVAnw5vqlpXW5VdUgqxKBK09F7zQgZlaypSPcvMIGRaYAFKQ+dNlmH PBxnTdJjFC5dRV8QPBePlMHlDYpMZMYNEtWsPqZz7oV12qPnmm3j/SvJ5/xmaCoIyJzP cyVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=vt/xl04ttfRW6GyQlqhX6psNn0S9uiI5ZWUekSum8y8=; fh=4rCG0PM8n0FOokGy8sSWDJpgPdCgp6yIXcpABJ7tUh0=; b=MkSqZEXGEZpYaIFwilPange+okXUChCRBNoe8SnlHrXiapirSKUO1vVQhE6bXwlptP V+dkMtcaOZrQMwqUEJ4N38LOpmvdS/Hw2nZM0205OOwUVUGF+zDV+/OY5hcvnQbTWYmx Rt67BcLn10oYjaMmR8HDWWZt5rhyX9sFfWOcLJmvLX8RaytJuupYNgQ0Oi4WreSNFJG7 RmpXtkfqPgOuimaVep8f7jOJc3na0R7ww3tXd+i0bHcA3K9GdCeqvZNFmyQ3f+WEj1Vu vmKeDhXrZDFUzt3gBbl95QY61PgsDKXDi64LZALAzdCzMOFvW4a9Gm1yOSdwQXlzin4w scRw==; 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=1769982992; x=1770587792; darn=lists.postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=vt/xl04ttfRW6GyQlqhX6psNn0S9uiI5ZWUekSum8y8=; b=JSoMQtbCLFKwiABugoNcLkf1+AqHV0WylEZ0MJY/XJOvfM8clQJ2Jc0I6UBUjDdwBA HTxZPNw0uDoVLEJeAzsvsyhyNMUl8X8r54ayegjkRFiuVrYW3cLHmAQudHR80SEKAXVC HE/29Tl3SHs0HkrK9Xqt+Oeu+i0rTcNENIEJnrwZeaW91ijo3DmRAYbm3HcV3wwxnzTW JTFjwN3Ysz/OYfENugl2Nsi9UbYvn/V2KSgar4wJBMuK77L3dw5S2RBN5tN0F7FLxSe+ CwYRBNYZ4kYEeLFsenMOZKNNzcLWpbbY2JZJjSWLqD+2uMVz1LYUU5QwWfLS/RQLQ3Cb VOEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769982992; x=1770587792; h=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=vt/xl04ttfRW6GyQlqhX6psNn0S9uiI5ZWUekSum8y8=; b=tHJCvOxt5lzNvktI+5hFVIBa+PktZ/tK67X33uagUgkuYyI5T0mudG9/XfalBt9BwB V5LhinK76DuOIlkagFjhHI7ZwW4yaGKTZjgegcLENU2PMlRLnY08SyToKkvcUcOcUoL5 Ryewj0AB0XaZyrugWzQaCZXuI6qJ5XOPNES2prSnpkKm0vMi+5IWiIHEoGXCQNuTVGrM IvH9VgYULcpxjabSTkyIO25MMh69VFBq3de+T1YZN//i6unlSpSlkIO84aa/i7tNBM3a ACleHm6MrlF4ywbY5LnlwFW8xpzRUXChZiAZMpcfMaUiX1foIfEbYTozCEmbicr4Hdhn KmNQ== X-Gm-Message-State: AOJu0YzV9H2njELnowsoBhmVRa6auWepkXneqMbNcEVe23U4vs3LdYU9 7P2pPZKHXQrUhVlS9Tp7bCIzTJUt9j51MTgNGujDS+vEM2vdhvRf05kGTWKpQzZbwBKKWOw4UVL y/wbEc2ntZkg82T8NyxUqtrdB3l80mdolag== X-Gm-Gg: AZuq6aIxjVcPC4Pahqi3K6TXsTAafLc+VewET66IZZMAcx4zJrCB8VIiKBEYZkgl2Rg gm3iOeR3jMyUbN3BE2h3RPZbh3terVh7hJnctKBLhcqVcZc4+ue8MltaCiSCz65MRUG4RmdT8ma OEwRLYjtrrb4IMVKdYXkANYgqFL3at/iWqij19m/2P/YyxGEHaRi+2G5JB8vZNfHF6HKMLlmRum ARYzd56x/TbKF7iH3xITGbwjgbzUA4NzAOtVC0NthcSyiJZ7YKVE8BudAWOpzYExWoGdnrc X-Received: by 2002:a05:6808:1b0c:b0:45c:a3bb:ad8f with SMTP id 5614622812f47-45f34d8964amr5554954b6e.56.1769982991746; Sun, 01 Feb 2026 13:56:31 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Ron Johnson Date: Sun, 1 Feb 2026 16:56:20 -0500 X-Gm-Features: AZwV_QjVrKevFHNxOYU4wb0RE1fvfH_ZCG_GEHoFITc6TpsWGb98iBuixq1aXa8 Message-ID: Subject: Re: Top -N Query performance issue and high CPU usage To: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="0000000000007b49520649ca47b8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000007b49520649ca47b8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Feb 1, 2026 at 4:47=E2=80=AFPM Peter J. Holzer w= rote: [snip] > If you do have that many simultaneous accesses to the landing page, and > you can't speed up the query significantly (I take it you've seen the > suggestion to check whether there's an index on > APP_schema.txn_tbl.tran_date), then maybe you don't need to perform it > for every user? I don't know what the query is supposed to do, but > unless the "ent_id" is really a user id, it doesn't seem to be specific > to the user. So maybe you can cache the result for a minute or an hour > and show the same result to everybody who logs in during that time. > That's what I was thinking, too: app server background process continually runs that query in a loop, feeding the results to a shared cache; the end user connections then read the latest version of the cached results. --=20 Death to , and butter sauce. Don't boil me, I'm still alive. lobster! --0000000000007b49520649ca47b8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Sun, Feb 1, 2026 at 4:47=E2=80=AFPM Pe= ter J. Holzer <hjp-pgsql@hjp.at&= gt; wrote:
[snip= ]=C2=A0
If you do have that many simultaneous accesses to the landing page, and
you can't speed up the query significantly (I take it you've seen t= he
suggestion to check whether there's an index on
APP_schema.txn_tbl.tran_date), then maybe you don't need to perform it<= br> for every user? I don't know what the query is supposed to do, but
unless the "ent_id" is really a user id, it doesn't seem to b= e specific
to the user. So maybe you can cache the result for a minute or an hour
and show the same result to everybody who logs in during that time.
=C2=A0
That's what I was thinking, too: app ser= ver=C2=A0background=C2=A0process continually runs that query in a loop, fee= ding the results to a shared cache; the end user connections then read the = latest version of the cached results.

--
Death to <Redacted>, and butter sauce.Don't boil me, I'm still alive.
<Redacted> lobs= ter!
--0000000000007b49520649ca47b8--