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.