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

From: Ron Johnson <ronljohnsonjr(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Top -N Query performance issue and high CPU usage
Date: 2026-02-01 21:56:20
Message-ID: CANzqJaBT6Uu6WDafuoRVXvpi7GgEZ9Jj2OJrN8sMZAstLNFjqQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, Feb 1, 2026 at 4:47 PM Peter J. Holzer <hjp-pgsql(at)hjp(dot)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!

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2026-02-02 01:06:17 Re: Top -N Query performance issue and high CPU usage
Previous Message Peter J. Holzer 2026-02-01 21:47:11 Re: Top -N Query performance issue and high CPU usage