Regarding Plan tree output(Index/Bitmap Scan)

From: Ajay P S <ajayps547(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Regarding Plan tree output(Index/Bitmap Scan)
Date: 2023-04-12 01:09:41
Message-ID: CAHjjAw17pXwqGQfZeGF24rucDmvW2UqmRoRgtibwQJUfkOA23A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I am trying to understand the Plan tree for select queries. Can you
please help me with the below queries?

1) Why is there a difference in plan tree for these two queries? User
table tidx1 has an index on column 'a' .
2) Why do we do Index scan and not Bitmap Index Scan for catalog tables?

postgres=# explain select * from pg_class where oid=2051;
QUERY PLAN
-------------------------------------------------------------------------------------
Index Scan using pg_class_oid_index on pg_class (cost=0.27..8.29
rows=1 width=265)
Index Cond: (oid = '2051'::oid)
(2 rows)

postgres=# explain select * from tidx1 where a=1;
QUERY PLAN
--------------------------------------------------------------------
Bitmap Heap Scan on tidx1 (cost=4.24..14.91 rows=11 width=8)
Recheck Cond: (a = 1)
-> Bitmap Index Scan on idx1 (cost=0.00..4.24 rows=11 width=0)
Index Cond: (a = 1)
(4 rows)

postgres=# select * from tidx1;
a | b
---+---
1 | 2
2 | 2
3 | 2
4 | 2
5 | 2
(5 rows)

Best,
Aj

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2023-04-12 01:18:08 Re: longfin missing gssapi_ext.h
Previous Message Michael Paquier 2023-04-12 01:07:08 Re: Add LZ4 compression in pg_dump