Hi,
This patch fixes a couple of small inaccuracies in the doc and the comment for FSM about index handling.
1. In the doc for pg_freespacemap, it currently says:
> For indexes, what is tracked is entirely-unused pages, rather than free space within pages. Therefore, the values are
notmeaningful, just whether a page is full or empty.
However, as what is tracked is entirely-unused pages, the values mean whether a page is "in-use or empty", rather than
"fullor empty".
2. In indexfsm.c the header comment says:
> * This is similar to the FSM used for heap, in freespace.c, but instead
> * of tracking the amount of free space on pages, we only track whether
> * pages are completely free or in-use. We use the same FSM implementation
> * as for heaps, using BLCKSZ - 1 to denote used pages, and 0 for unused.
However, in the code we see that used pages are marked with 0:
> /*
> * RecordUsedIndexPage - mark a page as used in the FSM
> */
> void
> RecordUsedIndexPage(Relation rel, BlockNumber usedBlock)
> {
> RecordPageWithFreeSpace(rel, usedBlock, 0);
> }
And free pages are marked with BLCKSZ - 1:
> /*
> * RecordFreeIndexPage - mark a page as free in the FSM
> */
> void
> RecordFreeIndexPage(Relation rel, BlockNumber freeBlock)
> {
> RecordPageWithFreeSpace(rel, freeBlock, BLCKSZ - 1);
> }
And so, this patch also fixes the comment's "using BLCKSZ - 1 to denote used pages, and 0 for unused" to be "using 0 to
denoteused pages, and BLCKSZ - 1 for unused".
While these changes are minor, I've seen how this can cause a bit of confusion, and it would be good to clarify it.
Best regards,
Alex Friedman
On Tue, Feb 25, 2025 at 07:24:14PM +0200, Alex Friedman wrote: > However, as what is tracked is entirely-unused pages, the values > mean whether a page is "in-use or empty", rather than "full or > empty". Ah, right, you are obviously right here. Applied and backpatched doen to 13 as the docs of pg_freespacemap have been incorrect for a long time. -- Michael
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера