Add SQL function to show total block numbers in the relation

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Add SQL function to show total block numbers in the relation

btkimurayuzk
Hello,


I propose new simple sql query, which shows total block numbers in the
relation.

I now reviewing this patch (https://commitfest.postgresql.org/25/2211/)
and I think,
it is usefull for knowing how many blocks there are in the relation to
determine whether we use VACUUM RESUME or not.

Of cource, we can know this value such as

select (pg_relation_size('t') /
current_setting('block_size')::bigint)::int;


but I think it is a litte bit complex.



Comment and feedback are very welcome.

Regards ,


Yu Kimura

show_total_block_numbers-20191030.patch (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Add SQL function to show total block numbers in the relation

Tom Lane-2
btkimurayuzk <[hidden email]> writes:
> I propose new simple sql query, which shows total block numbers in the
> relation.
> ...
> Of cource, we can know this value such as
> select (pg_relation_size('t') /
> current_setting('block_size')::bigint)::int;

I don't really see why the existing solution isn't sufficient.

                        regards, tom lane


Reply | Threaded
Open this post in threaded view
|

Re: Add SQL function to show total block numbers in the relation

Michael Paquier-2
On Wed, Oct 30, 2019 at 10:09:47AM -0400, Tom Lane wrote:
> btkimurayuzk <[hidden email]> writes:
>> I propose new simple sql query, which shows total block numbers in the
>> relation.
>> ...
>> Of cource, we can know this value such as
>> select (pg_relation_size('t') /
>> current_setting('block_size')::bigint)::int;
>
> I don't really see why the existing solution isn't sufficient.

+1.
--
Michael

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Add SQL function to show total block numbers in the relation

btkimurayuzk
In reply to this post by Tom Lane-2
> btkimurayuzk <[hidden email]> writes:
>> I propose new simple sql query, which shows total block numbers in the
>> relation.
>> ...
>> Of cource, we can know this value such as
>> select (pg_relation_size('t') /
>> current_setting('block_size')::bigint)::int;
>
> I don't really see why the existing solution isn't sufficient.

I think it's a little difficult to introduce the block size using two
values `current block size` and `reference size`
for beginners who are not familiar with the internal structure of
Postgres,

This is the reason why the existing solution was insufficient.

What do you think?

Regards,
Yu Kimura


Reply | Threaded
Open this post in threaded view
|

Re: Add SQL function to show total block numbers in the relation

Kyotaro Horiguchi-4
Hello, Kimura-san.

At Thu, 07 Nov 2019 17:04:51 +0900, btkimurayuzk <[hidden email]> wrote in

> > btkimurayuzk <[hidden email]> writes:
> >> I propose new simple sql query, which shows total block numbers in the
> >> relation.
> >> ...
> >> Of cource, we can know this value such as
> >> select (pg_relation_size('t') /
> >> current_setting('block_size')::bigint)::int;
> > I don't really see why the existing solution isn't sufficient.
>
> I think it's a little difficult to introduce the block size using two
> values `current block size` and `reference size`
> for beginners who are not familiar with the internal structure of
> Postgres,
>
> This is the reason why the existing solution was insufficient.
>
> What do you think?

Sorry, but I also vote -1 for the new function.

Size in block number is useless for those who doesn't understand the
notion of block, or block size. Those who understands the notion
should come up with the simple formula (except the annoying
casts). Anyone can find the clue to the base values by searching the
document in the Web with the keywords "block size" and "relation size"
or even with "table size". (FWIW, I would even do the same for the new
function if any...) If they need it so frequently, a user-defined
function is easily made up.

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center


Reply | Threaded
Open this post in threaded view
|

Re: Add SQL function to show total block numbers in the relation

Michael Paquier-2
On Thu, Nov 07, 2019 at 06:01:34PM +0900, Kyotaro Horiguchi wrote:
> Sorry, but I also vote -1 for the new function.

So do I.  If there are no objections, I will mark the patch as
rejected in the CF app.

> If they need it so frequently, a user-defined function is easily
> made up.

Yep.
--
Michael

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Add SQL function to show total block numbers in the relation

Michael Paquier-2
On Fri, Nov 08, 2019 at 09:30:56AM +0900, Michael Paquier wrote:
> On Thu, Nov 07, 2019 at 06:01:34PM +0900, Kyotaro Horiguchi wrote:
>> Sorry, but I also vote -1 for the new function.
>
> So do I.  If there are no objections, I will mark the patch as
> rejected in the CF app.

And done.
--
Michael

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Add SQL function to show total block numbers in the relation

btkimurayuzk
In reply to this post by Kyotaro Horiguchi-4
> Size in block number is useless for those who doesn't understand the
> notion of block, or block size. Those who understands the notion
> should come up with the simple formula (except the annoying
> casts). Anyone can find the clue to the base values by searching the
> document in the Web with the keywords "block size" and "relation size"
> or even with "table size". (FWIW, I would even do the same for the new
> function if any...) If they need it so frequently, a user-defined
> function is easily made up.
>
> regards.


I didn't know about the existence of the user-defined function .
I fully understood , Thanks .

Regards,

Yu Kimura