Re: Vacuum statistics

From: Alena Rybakina <a(dot)rybakina(at)postgrespro(dot)ru>
To: Ilia Evdokimov <ilya(dot)evdokimov(at)tantorlabs(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: jian he <jian(dot)universality(at)gmail(dot)com>, Alexander Korotkov <aekorotkov(at)gmail(dot)com>, Andrei Zubkov <zubkov(at)moonset(dot)ru>, Alena Rybakina <lena(dot)ribackina(at)yandex(dot)ru>, a(dot)lepikhov(at)postgrespro(dot)ru
Subject: Re: Vacuum statistics
Date: 2024-10-22 19:30:10
Message-ID: 995657bc-9966-47c0-b085-4c5e8886d249@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi!

On 16.10.2024 14:01, Alena Rybakina wrote:
>>
>> Thank you for rebasing.
>>
>> I have noticed that when I create a table or an index on this table,
>> there is no information about the table or index in
>> pg_stat_vacuum_tables and pg_stat_vacuum_indexes until we perform a
>> VACUUM.
>>
>> Example:
>>
>> CREATE TABLE t (i INT, j INT);
>> INSERT INTO t SELECT i/10, i/100 FROM GENERATE_SERIES(1,1000000) i;
>> SELECT * FROM pg_stat_vacuum_tables WHERE relname = 't';
>> ....
>> (0 rows)
>> CREATE INDEX ON t (i);
>> SELECT * FROM pg_stat_vacuum_indexes WHERE relname = 't_i_idx';
>> ...
>> (0 rows)
>>
>> I can see the entries after running VACUUM or executing
>> autovacuum. or when autovacuum is executed. I would suggest adding a
>> line about the relation even if it has not yet been processed by
>> vacuum. Interestingly, this issue does not occur with
>> pg_stat_vacuum_database:
>>
>> CREATE DATABASE example_db;
>> SELECT * FROM pg_stat_vacuum_database WHERE dbname = 'example_db';
>> dboid |       dbname | ...
>>  ...      | example_db | ...
>> (1 row)
>>
>> BTW, I recommend renaming the view pg_stat_vacuum_database to
>> pg_stat_vacuum_database_S_  for consistency with
>> pg_stat_vacuum_tables and pg_stat_vacuum_indexes
>>
> Thanks for the review. I'm investigating this. I agree with the
> renaming, I will do it in the next version of the patch.
>
I fixed it. I added the left outer join to the vacuum views and for
converting the coalesce function from NULL to null values.

I also fixed the code in getting database statistics - we can get it
through the existing pgstat_fetch_stat_dbentry function and fixed couple
of comments.

I attached a diff file, as well as new versions of patches.

--
Regards,
Alena Rybakina
Postgres Professional

Attachment Content-Type Size
v10-0001-Machinery-for-grabbing-an-extended-vacuum-statistics.patch text/x-patch 65.3 KB
v10-0002-Machinery-for-grabbing-an-extended-vacuum-statistics.patch text/x-patch 41.6 KB
v10-0003-Machinery-for-grabbing-an-extended-vacuum-statistics.patch text/x-patch 20.9 KB
v10-0004-Add-documentation-about-the-system-views-that-are-us.patch text/x-patch 24.2 KB
vacuum_stats_diff.no-cfbot text/plain 23.4 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-10-22 19:33:40 Re: Using Expanded Objects other than Arrays from plpgsql
Previous Message Melanie Plageman 2024-10-22 19:28:34 Re: EXPLAIN IndexOnlyScan shows disabled when enable_indexonlyscan=on