Re: pgstattuple: fix free space calculation

2024-09-09 Thread Tom Lane
=?UTF-8?Q?Fr=C3=A9d=C3=A9ric_Yhuel?= writes: > v4 patch attached. LGTM, pushed. regards, tom lane

Re: pgstattuple: fix free space calculation

2024-09-09 Thread Frédéric Yhuel
On 9/7/24 22:45, Tom Lane wrote: I wrote: Now alternatively you could argue that a "new" page isn't usable free space yet and so we should count it as zero, just as we don't count dead tuples as usable free space. You need VACUUM to turn either of those things into real free space. But that'

Re: pgstattuple: fix free space calculation

2024-09-09 Thread Frédéric Yhuel
Hi Tom, thanks for your review. On 9/7/24 22:10, Tom Lane wrote: I looked at this patch. I agree with making the change. However, I don't agree with the CF entry's marking of "target version: stable" (i.e., requesting back-patch). I think this falls somewhere in the gray area between a bug fi

Re: pgstattuple: fix free space calculation

2024-09-07 Thread Tom Lane
I wrote: > Now alternatively you could argue that a "new" page isn't usable free > space yet and so we should count it as zero, just as we don't count > dead tuples as usable free space. You need VACUUM to turn either of > those things into real free space. But that'd be a bigger definitional > c

Re: pgstattuple: fix free space calculation

2024-09-07 Thread Tom Lane
Rafia Sabih writes: > On Thu, 29 Aug 2024 at 16:53, Frédéric Yhuel > wrote: >> 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. I looked at this pa

Re: pgstattuple: fix free space calculation

2024-09-06 Thread Rafia Sabih
On Thu, 29 Aug 2024 at 16:53, Frédéric Yhuel 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 s

Re: pgstattuple: fix free space calculation

2024-08-30 Thread Andreas Karlsson
On 8/29/24 4:53 PM, Frédéric Yhuel wrote: So I think we should just use PageGetExactFreeSpace(). I agree, I feel that is the least surprising behavior because we currently sum tiny amounts of free space that is unusable anyway. E.g. imagine one million pages with 10 free bytes each, that look

Re: pgstattuple: fix free space calculation

2024-08-29 Thread Frédéric Yhuel
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 ju

Re: pgstattuple: fix free space calculation

2024-08-23 Thread Andreas Karlsson
On 8/23/24 12:02 PM, 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

Re: pgstattuple: fix free space calculation

2024-08-23 Thread Frédéric Yhuel
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 wi

Re: pgstattuple: fix free space calculation

2024-08-23 Thread Rafia Sabih
On Fri, 23 Aug 2024 at 11:01, Frédéric Yhuel wrote: > > > 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 thi

Re: pgstattuple: fix free space calculation

2024-08-23 Thread Frédéric Yhuel
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

Re: pgstattuple: fix free space calculation

2024-08-22 Thread Rafia Sabih
On Thu, 22 Aug 2024 at 10:11, Frédéric Yhuel wrote: > Hello, > > I think that pgstattuple should use PageGetExactFreeSpace() instead of > PageGetHeapFreeSpace() or PageGetFreeSpace(). The latter two compute the > free space minus the space of a line pointer. They are used like this in > the rest

pgstattuple: fix free space calculation

2024-08-22 Thread Frédéric Yhuel
Hello, I think that pgstattuple should use PageGetExactFreeSpace() instead of PageGetHeapFreeSpace() or PageGetFreeSpace(). The latter two compute the free space minus the space of a line pointer. They are used like this in the rest of the code (heapam.c): pagefree = PageGetHeapFreeSpace(pag