Re: PATCH: Attempt to make dbsize a bit more consistent - Mailing list pgsql-hackers

From gkokolatos@pm.me
Subject Re: PATCH: Attempt to make dbsize a bit more consistent
Date
Msg-id rgX4lsqk_b2FNrbUeyzOXv33ha9zda7cAPotddXNBpiKcr_21b91Gt47_MndIEG3owS17ONptgcXQ1NQ3ZvD2rjVsUOABV2ixzkcBl-qmP4=@pm.me
Whole thread Raw
In response to Re: PATCH: Attempt to make dbsize a bit more consistent  (Daniel Gustafsson <daniel@yesql.se>)
List pgsql-hackers




‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Wednesday, March 17, 2021 6:35 AM, Michael Paquier <michael@paquier.xyz> wrote:

> On Mon, Mar 15, 2021 at 03:10:59PM +0900, Michael Paquier wrote:
>
> > Anyway, as mentioned by other people upthread, I am not really
> > convinced either that we should have more flavors of size functions,
> > particularly depending on the relkind as this would be confusing for
> > the end-user. pg_relation_size() can already do this job for all
> > relkinds that use segment files, so it should still be able to hold
> > its ground and maintain a consistent behavior with what it does
> > currently.
>
> On top of the rest of my notes, there are two more things that would
> face a behavior change if making the existing functions go through
> table AMs, which would scan the data in the smgr:

I am not certain if you are referring to v5 (sent earlier than your mail)
or v4. Can you please verify?

>
> -   After a VACUUM, the relation would be reported with a size of 0,
>     while that may not be the case of on-disk files yet.

I am not really following. Apologies for it. The table AM may or may not
choose to go through smgr, depending on the implementation. The only
currently known implementation, heap, does invalidate smgr, based on
what I can see, after a VACUUM. I have not been able to create a test
case both with or without v5 of the patch where not the same result
would be returned.

What have I missed?

>
> -   Temporary tables of other sessions would be accessible.

I am not really certain I am following. Commit 6919b7e3294 from 2012
notes that calculate_relation_size can be safely applied to temp tables
of other sessions. v5 of the patch does not change that behaviour. Nor
did previous versions, but those are already obsolete.

>
>     So we would likely want a separate function. Another possibility,
>     which I find tempting, would be to push down the calculation logic
>     relying on physical files down to the table AM themselves with a new
>     dedicated callback (relation_size_physical?), as it seems to me that
>     the most important thing users want to know with this set of functions
>     is how much physical space is being consumed at one given point in
>     time. Attached is a small prototype I was just playing with.
>     --
>     Michael
>





pgsql-hackers by date:

Previous
From: Denis Hirn
Date:
Subject: [PATCH] Allow multiple recursive self-references
Next
From: James Coleman
Date:
Subject: Re: Nicer error when connecting to standby with hot_standby=off