Re: pgstattuple: fix free space calculation

Frédéric Yhuel <frederic.yhuel@dalibo.com>

From: Frédéric Yhuel <frederic.yhuel@dalibo.com>
To: Rafia Sabih <rafia.pghackers@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-08-23T09:01:27Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Consistently use PageGetExactFreeSpace() in pgstattuple.

Attachments


On 8/22/24 21:56, Rafia Sabih wrote:
> I agree with the approach here.
> A minor comment here is to change the comments in code referring to the 
> PageGetHeapFreeSpace.

Thank you Rafia. Here is a v2 patch.

I've also added this to the commit message:

Also, PageGetHeapFreeSpace() will return zero if there are already 
MaxHeapTuplesPerPage line pointers in the page and none are free. We 
don't want that either, because here we want to keep track of the free 
space after a page pruning operation even in the (very unlikely) case 
that there are MaxHeapTuplesPerPage line pointers in the page.