public inbox for [email protected]
help / color / mirror / Atom feedDoubts regarding pg_freespacemap extension
2+ messages / 2 participants
[nested] [flat]
* Doubts regarding pg_freespacemap extension
@ 2025-02-17 15:12 Rucha Kulkarni <[email protected]>
2025-02-18 16:21 ` Re: Doubts regarding pg_freespacemap extension Adrian Klaver <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: Rucha Kulkarni @ 2025-02-17 15:12 UTC (permalink / raw)
To: [email protected]
Hi PostgreSQL Community,
While exploring the pg_freespacemap extension, I came across a few doubts
and would appreciate any insights or clarifications:
1. In the code, it defines NonLeafNodesPerPage as (BLCKSZ / 2 - 1) as can
be seen here:
https://github.com/postgres/postgres/blob/master/src/include/storage/fsm_internals.h#L54
For a binary tree, (BLCKSZ - 1) / 2 seems more appropriate when calculating
the number of non-leaf nodes. Why does the code approximate it to (BLCKSZ /
2) - 1 ?
2. According to the comment mentioned here
https://github.com/postgres/postgres/blob/master/src/backend/storage/freespace/indexfsm.c#L19
, 0 is used to denote unused pages and (BLCKSZ - 1) for used pages for
indexes. This seems reversed, shouldn't 0 indicate space available for used
pages, and (BLCKSZ - 1) indicate space available for unused pages?
3. Whenever I check the values for B-tree indexes, I observe all values to
be 0.
postgres=# select * from pg_freespace('xyz_btree');
blkno | avail
-------+-------
0 | 0
1 | 0
2 | 0
3 | 0
4 | 0
(5 rows)
How can non-zero values be observed in B-tree indexes?
4. For BRIN indexes, I see a value of 8128 instead of 8191 (BLCKSZ - 1). Is
this due to the BRIN header occupying space, leading to category 254?
postgres=# select * from pg_freespace('xyz_brin');
blkno | avail
-------+-------
0 | 0
1 | 0
2 | 8128
(3 rows)
Regards,
Rucha Kulkarni
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Doubts regarding pg_freespacemap extension
2025-02-17 15:12 Doubts regarding pg_freespacemap extension Rucha Kulkarni <[email protected]>
@ 2025-02-18 16:21 ` Adrian Klaver <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Adrian Klaver @ 2025-02-18 16:21 UTC (permalink / raw)
To: Rucha Kulkarni <[email protected]>; [email protected]
On 2/17/25 07:12, Rucha Kulkarni wrote:
> Hi PostgreSQL Community,
>
> While exploring the pg_freespacemap extension, I came across a few
> doubts and would appreciate any insights or clarifications:
>
>
> 3. Whenever I check the values for B-tree indexes, I observe all values
> to be 0.
From here:
https://www.postgresql.org/docs/current/pgfreespacemap.html
"For indexes, what is tracked is entirely-unused pages, rather than free
space within pages. Therefore, the values are not meaningful, just
whether a page is full or empty."
>
> Regards,
>
> Rucha Kulkarni
>
--
Adrian Klaver
[email protected]
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2025-02-18 16:21 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-02-17 15:12 Doubts regarding pg_freespacemap extension Rucha Kulkarni <[email protected]>
2025-02-18 16:21 ` Adrian Klaver <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox