Re: pgstattuple: fix free space calculation

From: Frédéric Yhuel <frederic(dot)yhuel(at)dalibo(dot)com>
To: Rafia Sabih <rafia(dot)pghackers(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pgstattuple: fix free space calculation
Date: 2024-08-23 10:51:15
Message-ID: c55fc210-b356-4569-9dd2-44a370205f17@dalibo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 8/23/24 12:02, Rafia Sabih wrote:
> On the other hand, this got me thinking about the purpose of this space
> information.
> If we want to understand that there's still some space for the tuples in
> a page, then using PageGetExactFreeSpace is not doing justice in case of
> heap page, because we will not be able to add any more tuples there if
> there are already MaxHeapTuplesPerPage tuples there.

We won't be able to add, but we will be able to update a tuple in this
page. It's hard to test, because I can't fit more than 226 tuples on a
single page, while MaxHeapTuplesPerPage = 291 on my machine :-)

In any case, IMVHO, pgstattuple shouldn't answer to the question "can I
add more tuples?". The goal is for educational, introspection or
debugging purposes, and we want the exact amount of free space.

Best regards,
Frédéric

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2024-08-23 10:56:24 Re: Pgoutput not capturing the generated columns
Previous Message Rafia Sabih 2024-08-23 10:30:12 Re: Trim the heap free memory