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

From: yudhi s <learnerdatabase99(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org, Ron Johnson <ronljohnsonjr(at)gmail(dot)com>, hjp-pgsql(at)hjp(dot)at
Subject: Re: Top -N Query performance issue and high CPU usage
Date: 2026-02-02 04:17:06
Message-ID: CAEzWdqf+b+7JDRNzJVqWKyF8N8Aa2CZC5B_o1xZLDWozqV-RUA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Feb 2, 2026 at 3:17 AM Peter J. Holzer <hjp-pgsql(at)hjp(dot)at> wrote:

>
> However, maybe you didn't mean that. There are relatively few
> applications where thousands of users log in within a second. Maybe you
> just meant that there would be thousands of users logged in in total. If
> so, how many simultaneus queries do you really expect?
>
> 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.
>
>
Thank you so much. I need to get back on the exact number of such queries
which can hit the database. However, as 1000 of users will be there, so the
possibility of all logging into the system on the same page at same time
needs to be found out. Will double check on this.

However, when you said caching :- The results on the base tables are going
to be ~30-50 million. This landing page has filters on it so it may be of
30+ different combinations based on the user's choice. So do you suggest ,
we will populate the base data in a materialized view(named like "landing
page data") which we can refresh (maybe once in ~5 minutes behind the
scenes) and then that can be queried in the landing page directly. And we
can have suitable indexes created on the materialized view based on the
dynamic filter criteria?

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message yudhi s 2026-02-02 06:33:08 Re: Top -N Query performance issue and high CPU usage
Previous Message Adrian Klaver 2026-02-02 01:06:17 Re: Top -N Query performance issue and high CPU usage