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

From: yudhi s <[email-masked]>
Date: Sat, 31 Jan 2026 19:00:03 +0530

Hello Experts,
 We have a "Select" query which is using three to five main transaction
tables (txn_tbl, txn_status, txn_decision, txn_sale, ath) holding ~2million
rows in each of them(which is going to increase to have ~50-100million in
future) and others(6-7) tables out of which some are master and some other
small tables.

When we are running this query , and it's taking ~2-3seconds , however when
we hit this query from 10-15 session at same time its causing CPU spike up
to ~50-60% for the DB instance and this is increasing and touching 90% when
we are increasing the hits further to 40-50 times concurrently.

This query is going to be called in the first page of an UI screen and is
supposed to show the latest 1000 rows based on a certain transaction date.
This query is supposed to allow thousands of users to hit this same query
at the first landing page at the same time.  Its postgres version 17.  The
instance has 2-VCPU and 16GB RAM.

I have the following questions.

1)Why is this query causing a high cpu spike ,if there is any way in
postgres to understand what part/line of the query is contributing to the
high cpu time?
2)How can we tune this query to further reduce response time and mainly CPU
consumption ? Is any additional index or anything will make this plan
better further?
3) Is there any guidance or best practices exists , to create/design top
N-queries for such UI scenarios where performance is an important factor?
4)And based on the CPU core and memory , is there any calculation by using
which , we can say that this machine can support a maximum N number of
concurrent queries of such type beyond which we need more cpu cores
machines?

Below is the query and its current plan:-
https://gist.github.com/databasetech0073/6688701431dc4bf4eaab8d345c1dc65f

Regards
Yudhi

---

From: David Mullineux <[email-masked]>
Date: Sat, 31 Jan 2026 14:41:18 +0000

On Sat, 31 Jan 2026, 13:30 yudhi s, <[email-masked]> wrote:

> When we are running this query , and it's taking ~2-3seconds , however
> when we hit this query from 10-15 session at same time its causing CPU
> spike up to ~50-60% for the DB instance and this is increasing and touching
> 90% when we are increasing the hits further to 40-50 times concurrently.
>
> 2)How can we tune this query to further reduce response time and mainly
> CPU consumption ? Is any additional index or anything will make this plan
> better further?

Plan says it's using temp files for sorting....I would suggest you increase
work_mem for this to avoid temp.fike creation...Although not the answer to
all your problems, it would be a good start .

---

From: Adrian Klaver <[email-masked]>
Date: Sat, 31 Jan 2026 08:14:48 -0800

> This query is going to be called in the first page of an UI screen and 
> is supposed to show the latest 1000 rows based on a certain transaction 
> date. This query is supposed to allow thousands of users to hit this 
> same query at the first landing page at the same time. Its postgres 
> version 17.  The instance has 2-VCPU and 16GB RAM.

1) Without even looking at the plan I'm going to say 2-VCPU and 16GB RAM 
and is insufficient resources for what you want to do.

2) You will need to provide the schema definitions for the tables involved.

4)And based on the CPU core and memory , is there any calculation by 
using which , we can say that this machine can support a maximum N 
number of concurrent queries of such type beyond which we need more cpu 
cores machines?

You already have the beginnings of a chart:

1 session 2-3 secs

10-15 sessions 50-60% usage

40-50 sessions 90% usage

-- 
Adrian Klaver
[email-masked]

---

From: yudhi s <[email-masked]>
Date: Sun, 1 Feb 2026 01:09:47 +0530

>
>
>>
> Plan says it's using temp files for sorting....I would suggest you
> increase work_mem for this to avoid temp.fike creation...Although not the
> answer to all your problems, it would be a good start .
>
>
Even setting work_mem to 64MB remove all the "temp read" and showig all
memory reads, but still we are seeing similar cpu spike when executing this
query from multiple sessions and also the response time is staying same.

---

From: yudhi s <[email-masked]>
Date: Sun, 1 Feb 2026 01:16:56 +0530

Thank you.

> and is insufficient resources for what you want to do.
Can you please explain a bit in detail, how much minimum VCPU and RAM will
be enough resources to suffice this requirement? and you normally do that
calculation?

> Do you mean table DDL or just the index definitions on the tables should
help?

Also i was trying to understand , by just looking into the "explain
analyze" output, is there any way we can tie the specific step in the plan
, which is the major contributor of the cpu resources? Such that we can
then try to fix that part rather than looking throughout the query as its
big query?

And if any suggestion to improve the TOP-N queries where the base table may
have many rows in it.

---

From: Ron Johnson <[email-masked]>
Date: Sat, 31 Jan 2026 16:05:17 -0500

> then try to fix that part rather than looking throughout the query as its

It looks like 71% (748ms of a total 1056ms) of elapsed time is taken by the
c_1.tran_date  external sort on line 150.

That, obviously, is what you should work on.

1. You say you increased work_mem.  From what, to what?
2. But that it did not reduce execution time.  Please post the EXPLAIN from
after increasing work_mem.
3. Did you remember to run SELECT pg_reload_conf(); after increasing
work_mem?
4. Is there an index on APP_schema.txn_tbl.tran_date?

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

---

From: Luigi Nardi <[email-masked]>
Date: Sun, 1 Feb 2026 13:54:54 +0100

On Sat, Jan 31, 2026 at 10:05 PM Ron Johnson <[email-masked]>
wrote:

>> Can you please explain a bit in detail, how much minimum VCPU and RAM
>> will be enough resources to suffice this requirement? and you normally do
>> that calculation?
>>
>>
> It looks like 71% (748ms of a total 1056ms) of elapsed time is taken by
> the c_1.tran_date  external sort on line 150.
>
> 2. But that it did not reduce execution time.  Please post the EXPLAIN
> from after increasing work_mem.
> And if any suggestion to improve the TOP-N queries where the base table
>> may have many rows in it.
>>
>
>
The DBtune Free Edition <http://app.dbtune.com> can help you find the
correct adjustments for work_mem and other server parameters
<https://dbtune.com/blog/dbtunes-multi-dimensional-performance-tuning-space>.
It's designed to help optimize your PostgreSQL runtime for your current
hardware setup.

---

From: "Peter J. Holzer" <[email-masked]>
Date: Sun, 1 Feb 2026 22:47:11 +0100

On 2026-02-01 01:16:56 +0530, yudhi s wrote:
> Can you please explain a bit in detail, how much minimum VCPU and RAM will be
> enough resources to suffice this requirement? and you normally do that
> calculation?

You wrote:

| This query is supposed to allow thousands of users to hit this same
| query at the first landing page at the same time.

If you meant that literally, you would need thousands of cores to handle
those thousands of simultaneous queries and enough RAM for thousands of
sessions, each performing a rather complex query. So possibly hundreds
of maybe even thousands of gigabytes, not 16.

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.

        hjp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | [email-masked]         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

---

From: Ron Johnson <[email-masked]>
Date: Sun, 1 Feb 2026 16:56:20 -0500

On Sun, Feb 1, 2026 at 4:47 PM Peter J. Holzer <[email-masked]> wrote:
[snip]

> 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.

---

From: Adrian Klaver <[email-masked]>
Date: Sun, 1 Feb 2026 17:06:17 -0800

On 1/31/26 11:46, yudhi s wrote:
> will be enough resources to suffice this requirement? and you normally 
> do that calculation?

Don't know what the minimum requirements are. It would depend on many 
variables 1) The plan being chosen, which in turn depends on the schema 
information as well as the data turnover. 2) What the VCPU is actually 
emulating. 3) The efficiency of of the virtual machines/containers with 
regard to accessing memory and storage. 4) The service limits of the 
virtualization. 5) What the storage system and how performant it is.

In other words this is something you will need to test and derive your 
own formula for.

> Do you mean table DDL or just the index definitions on the tables should 

Basically what you get in psql when you do \d some_table.

> analyze" output, is there any way we can tie the specific step in the 
> plan , which is the major contributor of the cpu resources? Such that we 
> can then try to fix that part rather than looking throughout the query 
> as its big query?
> 

Feedback-ID: i76984098:Fastmail
Date: Sun, 1 Feb 2026 17:06:17 -0800
Subject: Re: Top -N Query performance issue and high CPU usage
To: yudhi s <[email-masked]>
Cc: pgsql-general <[email-masked]>
From: Adrian Klaver <[email-masked]>
Archived-At: <https://www.postgresql.org/message-id/b87f6128-5df8-4fca-ae25-da7c7fa870eb%40aklaver.com>

On 1/31/26 11:46, yudhi s wrote:
> will be enough resources to suffice this requirement? and you normally 
> do that calculation?

Don't know what the minimum requirements are. It would depend on many 
variables 1) The plan being chosen, which in turn depends on the schema 
information as well as the data turnover. 2) What the VCPU is actually 
emulating. 3) The efficiency of of the virtual machines/containers with 
regard to accessing memory and storage. 4) The service limits of the 
virtualization. 5) What the storage system and how performant it is.

In other words this is something you will need to test and derive your 
own formula for.

> Do you mean table DDL or just the index definitions on the tables should 

Basically what you get in psql when you do \d some_table.

> analyze" output, is there any way we can tie the specific step in the 
> plan , which is the major contributor of the cpu resources? Such that we 
> can then try to fix that part rather than looking throughout the query 
> as its big query?
>

---

From: yudhi s <[email-masked]>
Date: Mon, 2 Feb 2026 09:47:06 +0530

> 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?

---

From: yudhi s <[email-masked]>
Date: Mon, 2 Feb 2026 17:09:21 +0530

> and show the same result to everybody who logs in during that time.

There was no index on column  tran_date  , I created one and it's making
the query finish in  ~200ms, a lot faster than in the past. Below is the
portion of the query and its plan which actually consumes most of the
resource and time post the new index creation.

https://gist.github.com/databasetech0073/344df46c328e02b98961fab0cd221492

1) Now the part  which takes time is the "nested loop" join on the
"ent_id"  column. Can we do anything to make it much better/faster?

2) Also another question I had was,  with this new index the table scan of
txn_tbl is now fully eliminated by the "Index Scan Backward" even i have
other columns from that table projected in the query, so how its getting
all those column values without visiting table but just that index scan
backward operation?

---

From: Ron Johnson <[email-masked]>
Date: Mon, 2 Feb 2026 08:34:31 -0500

> all those column values without visiting table but just that index scan

Reading through EXPLAIN output isn't always a mystery.

Search for "actual time" and you'll find row 53, which is the "deepest"
(most nested) row with the highest actual time.

That tells you where the time is now spent, and what it's doing.

---

From: yudhi s <[email-masked]>
Date: Mon, 2 Feb 2026 19:23:00 +0530

On Mon, Feb 2, 2026 at 7:04 PM Ron Johnson <[email-masked]> wrote:

>> 2) Also another question I had was,  with this new index the table scan
>> of txn_tbl is now fully eliminated by the "Index Scan Backward" even i have
My apologies if i misunderstand the plan, But If I see,   it's spending
~140ms(140ms-6ms) i.e. almost all the time now, in performing the below
nested loop join. So my question was , is there any possibility to reduce
the resource consumption or response time further here?  Hope my
understanding is correct here.

-> Nested Loop (cost=266.53..1548099.38 rows=411215 width=20) (actual time=
*6.009..147.695* rows=1049 loops=1)
Join Filter: ((df.ent_id)::numeric = m.ent_id)
Rows Removed by Join Filter: 513436
Buffers: shared hit=1939

---

From: Ron Johnson <[email-masked]>
Date: Mon, 2 Feb 2026 10:00:47 -0500

On Mon, Feb 2, 2026 at 8:53 AM yudhi s <[email-masked]> wrote:

>>> There was no index on column  tran_date  , I created one and it's
>>> making the query finish in  ~200ms, a lot faster than in the past. Below is
>>> the portion of the query and its plan which actually consumes most of the

I don't see m.ent_id in the actual query.  Did you only paste a portion of
the query?

Also, casting in a JOIN typically brutalizes the ability to use an index.

---

From: yudhi s <[email-masked]>
Date: Tue, 3 Feb 2026 00:09:24 +0530

On Mon, Feb 2, 2026 at 8:57 PM Ron Johnson <[email-masked]> wrote:

>> -> Nested Loop (cost=266.53..1548099.38 rows=411215 width=20) (actual
>> time=*6.009..147.695* rows=1049 loops=1)
> I don't see m.ent_id in the actual query.  Did you only paste a portion
> of the query?
>
Actually i tried executing the first two CTE where the query was spending
most of the time  and teh alias has changed. Also here i have changed the
real table names before putting it here, hope that is fine.
However , i verified the data type of the ent_id column in "ent" its "int8"
and in table "txn_tbl" is "numeric 12", so do you mean to say this
difference in the data type is causing this high response time during the
nested loop join? My understanding was it will be internally castable
without additional burden. Also, even i tried creating an index on the
"(df.ent_id)::numeric"
its still reulting into same plan and response time.

---

From: Ron Johnson <[email-masked]>
Date: Mon, 2 Feb 2026 14:31:06 -0500

On Mon, Feb 2, 2026 at 1:39 PM yudhi s <[email-masked]> wrote:

> most of the time  and teh alias has changed.
>

We need to see everything, not just what you think is relevant.

> Also here i have changed the real table names before putting it here, hope
> that is fine.
> However , i verified the data type of the ent_id column in "ent" its
> "int8" and in table "txn_tbl" is "numeric 12", so do you mean to say this
> without additional burden. Also, even i tried creating an index on the "(df.ent_id)::numeric"

If you'd shown the "\d" table definitions like Adrian asked two days ago,
we'd know what indexes are on each table, and not have to beg you to
dispense dribs and drabs of information.

---

From: yudhi s <[email-masked]>
Date: Tue, 3 Feb 2026 02:13:01 +0530

On Tue, Feb 3, 2026 at 1:01 AM Ron Johnson <[email-masked]> wrote:

>> Also here i have changed the real table names before putting it here,
>> hope that is fine.
I am unable to run "\d" from the dbeaver sql worksheet. However,  I have
fetched the DDL for the three tables and their selected columns, used in
the smaller version of the query and its plan , which I recently updated.

https://gist.github.com/databasetech0073/e4290b085f8f974e315fb41bdc47a1f3

Regards
Yudhi

---

From: Ron Johnson <[email-masked]>
Date: Mon, 2 Feb 2026 18:19:50 -0500

On Mon, Feb 2, 2026 at 3:43 PM yudhi s <[email-masked]> wrote:

>>>>> My apologies if i misunderstand the plan, But If I see,   it's
>>>>> spending ~140ms(140ms-6ms) i.e. almost all the time now, in performing the
>>>>> below nested loop join. So my question was , is there any possibility to
>>>>> reduce the resource consumption or response time further here?  Hope my
>>>> I don't see m.ent_id in the actual query.  Did you only paste a
>>>> portion of the query?
>>>>
>>> Actually i tried executing the first two CTE where the query was
>>> spending most of the time  and teh alias has changed.
>>>
>>

Lines 30-32 are where most of the time and effort are taken.

I can't be certain, but changing APP_schema.ent.ent_id from NUMERIC to int8
(with a CHECK constraint to, well, constrain it to 12 digits, if really
necessary) is something I'd test.

---

From: yudhi s <[email-masked]>
Date: Tue, 3 Feb 2026 14:56:14 +0530

On Tue, Feb 3, 2026 at 4:50 AM Ron Johnson <[email-masked]> wrote:

>>> If you'd shown the "\d" table definitions like Adrian asked two days
>>> ago, we'd know what indexes are on each table, and not have to beg you to
> I can't be certain, but changing APP_schema.ent.ent_id from NUMERIC to
> int8 (with a CHECK constraint to, well, constrain it to 12 digits, if
> really necessary) is something I'd test.
>
> --
>

Thank you so much.

After making the data types equal on both tables for the column ent_id the
plan now looks as below. The costing function sinow removed. So it must be
helping reduce CPU cycle consumption to some extent, But,  I still see
~100ms is spent in this step. Is there anything we can do to further drop
the response time here? Or it's the best time we can get here.

  ->  Nested Loop  (cost=262.77..1342550.91 rows=579149 width=20) (*actual
time=6.406..107.946* rows=1049 loops=1)
              Join Filter: (*df.ent_id = m.ent_id*)
              Rows Removed by Join Filter: 514648
              Buffers: shared hit=1972

Also I do see in some other steps in the plan , the casting function is
getting used. For example in the below filter. Here txn_tbl_type_nm is
defined as Varchar(25) and still it's trying to cast it to Text. Can we do
anything to avoid these force casts as these must consume the CPU cycles?

    AND txn_tbl_dcsn.txn_tbl_txn_sts_tx NOT IN ('STATUS_A','STATUS_B')
    WHERE txn_tbl.txn_tbl_type_nm IN ('TYPE1','TYPE2','TYPE3')

  ->  Index Scan Backward using txn_tbl_due_dt_idx on txn_tbl df
 (cost=0.43..115879.87 rows=1419195 width=20) (actual time=0.019..20.377
rows=43727 loops=1)
Filter: *((txn_tbl_type_nm)::text = ANY ('{TYPE1,TYPE2,TYPE3}'::text[])*)
Rows Removed by Filter: 17
Buffers: shared hit=1839

The plan is as below.

https://gist.github.com/databasetech0073/558377c1939a9291e7b72b1cbac7c9f9

Regards
Yudhi

---

From: Ron Johnson <[email-masked]>
Date: Tue, 3 Feb 2026 10:59:51 -0500

On Tue, Feb 3, 2026 at 4:26 AM yudhi s <[email-masked]> wrote:

>>>>>>> -> Nested Loop (cost=266.53..1548099.38 rows=411215 width=20)
>>>>>>> (actual time=*6.009..147.695* rows=1049 loops=1)

Hmm.  What does pg_stat_user_tables say about when you last analyzed and
vacuumed APP_schema.txn_tbl and APP_schema.ent?

Beyond "aggressively keep those two tables analyzed, via reducing
autovacuum_analyze_scale_factor to something like 0.05, and adding
'vacuumdb -d mumble -j2 --analyze-only -t APP_schema.txn_tbl -t
APP_schema.ent' to crontab", I'm out of ideas.  An 85% speed improvement is
nothing to sneeze at, though.

> Rows Removed by Filter: 17

There is no VARCHAR or CHAR; there is only TEXT.  Thus, this is 100%
expected and normal.

---

From: Adrian Klaver <[email-masked]>
Date: Tue, 3 Feb 2026 08:07:39 -0800

> There is no VARCHAR or CHAR; there is only TEXT.  Thus, this is 100% 

What Ron is saying is that there are varchar and char types, but they 
boil down to text per:

https://www.postgresql.org/docs/current/datatype-character.html

"text is PostgreSQL's native string data type, in that most built-in 
functions operating on strings are declared to take or return text not 
character varying. For many purposes, character varying acts as though 
it were a domain over text."

As to performance see:

"
Tip

There is no performance difference among these three types, apart from 
increased storage space when using the blank-padded type, and a few 
extra CPU cycles to check the length when storing into a 
length-constrained column. While character(n) has performance advantages 
in some other database systems, there is no such advantage in 
PostgreSQL; in fact character(n) is usually the slowest of the three 
because of its additional storage costs. In most situations text or 
character varying should be used instead.
"

---

From: [email-masked]
Date: Wed, 4 Feb 2026 15:48:13 +0000 (UTC)

Have you tried adding an index to txn_tbl.txn_type? 
And a vacuum on all tables? It seems the visibility map is outdated.

I'm using https://explain.dalibo.com to view the plan visually; it's more convenient.

You could use the option to periodically save the results of queries with common filters to another table, and then retrieve the results from that table when a user performs a query with their own filters.
You should also store the user's query results somewhere for a while to prevent excessive database access.

I imagine this is some kind of dashboard that each user is taken to after authenticating. It looks nice in presentations, but after a while in production, it can make the system unusable. I had to remove similar charts from the homepage of a system because after a year of work, they were taking a minute to load.

 On Saturday, January 31, 2026 at 08:30:33 AM GMT-5, yudhi s <[email-masked]> wrote:
 Hello Experts,
 We have a "Select" query which is using three to five main transaction tables (txn_tbl, txn_status, txn_decision, txn_sale, ath) holding ~2million rows in each of them(which is going to increase to have ~50-100million in future) and others(6-7) tables out of which some are master and some other small tables.

When we are running this query , and it's taking ~2-3seconds , however when we hit this query from 10-15 session at same time its causing CPU spike up to ~50-60% for the DB instance and this is increasing and touching 90% when we are increasing the hits further to 40-50 times concurrently.

This query is going to be called in the first page of an UI screen and is supposed to show the latest 1000 rows based on a certain transaction date. This query is supposed to allow thousands of users to hit this same query at the first landing page at the same time.

Its postgres version 17.  The instance has 2-VCPU and 16GB RAM.

1)Why is this query causing a high cpu spike ,if there is any way in postgres to understand what part/line of the query is contributing to the high cpu time?
2)How can we tune this query to further reduce response time and mainly CPU consumption ? Is any additional index or anything will make this plan better further?
3) Is there any guidance or best practices exists , to create/design top N-queries for such UI scenarios where performance is an important factor?
4)And based on the CPU core and memory , is there any calculation by using which , we can say that this machine can support a maximum N number of concurrent queries of such type beyond which we need more cpu cores machines?
Below is the query and its current plan:-https://gist.github.com/databasetech0073/6688701431dc4bf4eaab8d345c1dc65f
RegardsYudhi

---

From: yudhi s <[email-masked]>
Date: Thu, 5 Feb 2026 14:05:49 +0530

On Wed, Feb 4, 2026 at 9:18 PM <[email-masked]> wrote:

> You could use the option to periodically save the results of queries with
> common filters to another table, and then retrieve the results from that
> table when a user performs a query with their own filters.
> I imagine this is some kind of dashboard that each user is taken to after
> authenticating. It looks nice in presentations, but after a while in
> production, it can make the system unusable. I had to remove similar charts
> from the homepage of a system because after a year of work, they were
> taking a minute to load.
>
>
> at the first landing page at the same time.
>
As folks suggested , adding an index on "tran_date" and combining the CTE
to two, and making the data type equal for the "ent_id" has helped reduce
the response to a large extent. Now I am trying to see if we can reduce any
further. As most of the time(100-20=~80ms) is now on materialize loop which
is happening 43K times.

Also thinking if adding "txn_tbl_type_nm" column to the index i.e.
composite index on (tran_date,txn_tbl_type_nm) will be advisable , in cases
where , ~500K rows will be filtered  by the *txn_tbl_type_nm *filter
criteria (currently its just 17 rows getting filtered though for this case).

-> Nested Loop (cost=263.20..1680202.56 rows=483106 width=20) (actual
time=6.421..111.220 rows=1000 loops=1)
Buffers: shared hit=6168
-> Nested Loop (cost=262.77..1342550.91 rows=579149 width=20) (*actual
time=6.406..107.946* rows=1049 loops=1)
Join Filter: (df.ent_id = m.ent_id)
Rows Removed by Join Filter: 514648
Buffers: shared hit=1972
-> Index Scan Backward using txn_tbl_due_dt_idx on txn_tbl df
(cost=0.43..115879.87 rows=1419195 width=20) (*actual time=0.019..20.377*
rows=43727 loops=1)
*Filter: ((txn_tbl_type_nm)::text = ANY ('{TYPE1,TYPE2,TYPE3}'::text[]))*
*Rows Removed by Filter: 17*
Buffers: shared hit=1839
-> Materialize (cost=262.35..364.01 rows=58 width=8) (actual
time=0.000..0.001 rows=12 loops=43727)
Buffers: shared hit=133

Regards
Yudhi