Re: Top -N Query performance issue and high CPU usage - Mailing list pgsql-general

From Ron Johnson
Subject Re: Top -N Query performance issue and high CPU usage
Date
Msg-id CANzqJaBT6Uu6WDafuoRVXvpi7GgEZ9Jj2OJrN8sMZAstLNFjqQ@mail.gmail.com
Whole thread Raw
In response to Re: Top -N Query performance issue and high CPU usage  ("Peter J. Holzer" <hjp-pgsql@hjp.at>)
List pgsql-general
On Sun, Feb 1, 2026 at 4:47 PM Peter J. Holzer <hjp-pgsql@hjp.at> wrote:
[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.

--
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!

pgsql-general by date:

Previous
From: "Peter J. Holzer"
Date:
Subject: Re: Top -N Query performance issue and high CPU usage
Next
From: Adrian Klaver
Date:
Subject: Re: Top -N Query performance issue and high CPU usage