Re: pgstattuple: fix free space calculation

From: Rafia Sabih <rafia(dot)pghackers(at)gmail(dot)com>
To: Frédéric Yhuel <frederic(dot)yhuel(at)dalibo(dot)com>
Cc: Andreas Karlsson <andreas(at)proxel(dot)se>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pgstattuple: fix free space calculation
Date: 2024-09-06 11:18:39
Message-ID: CA+FpmFccphL3TrZwqgM2CbLUedfMNjFAQsiC+NRhcobg=ggawQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 29 Aug 2024 at 16:53, Frédéric Yhuel <frederic(dot)yhuel(at)dalibo(dot)com>
wrote:

>
>
> On 8/23/24 12:51, Frédéric Yhuel wrote:
> >
> >
> > 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.
>
> Sorry, that's not true.
>
> So in this marginal case we have free space that's unusable in practice.
> No INSERT or UPDATE (HOT or not) is possible inside the page.
>
> I don't know what pgstattuple should do in this case.
>
> However, we should never encounter this case in practice (maybe on some
> exotic architectures with strange alignment behavior?). As I said, I
> can't fit more than 226 tuples per page on my machine, while
> MaxHeapTuplesPerPage is 291. Am I missing something?
>
> Besides, pgstattuple isn't mission critical, is it?
>

Yes, also as stated before I am not sure of the utility of this field in
real-world scenarios.
So, I can not comment more on that. That was just one thought that popped
into my head.
Otherwise, the idea seems fine to me.

>
> So I think we should just use PageGetExactFreeSpace().
>
> Here is a v3 patch. It's the same as v2, I only removed the last
> paragraph in the commit message.
>

Thanks for the new patch. LGTM.

>
> Thank you Rafia and Andreas for your review and test.
>
Thanks to you too.

>
> Best regards,
> Frédéric

--
Regards,
Rafia Sabih

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2024-09-06 11:18:51 Re: Invalid Assert while validating REPLICA IDENTITY?
Previous Message Yugo Nagata 2024-09-06 11:10:43 Remove emode argument from XLogFileRead/XLogFileReadAnyTLI