Re: Top -N Query performance issue and high CPU usage

Ron Johnson <ronljohnsonjr@gmail.com>

From: Ron Johnson <ronljohnsonjr@gmail.com>
To: pgsql-general@lists.postgresql.org
Date: 2026-02-01T21:56:20Z
Lists: 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!