Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t93pu-007WSy-Py for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Nov 2024 14:50:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1t93ps-00GHLk-5c for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Nov 2024 14:50:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t93pr-00GHLc-Ok for pgsql-hackers@lists.postgresql.org; Thu, 07 Nov 2024 14:50:12 +0000 Received: from forward100b.mail.yandex.net ([178.154.239.147]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t93pn-000gsf-Nz for pgsql-hackers@postgresql.org; Thu, 07 Nov 2024 14:50:11 +0000 Received: from mail-nwsmtp-smtp-production-main-60.sas.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-60.sas.yp-c.yandex.net [IPv6:2a02:6b8:c11:1115:0:640:1385:0]) by forward100b.mail.yandex.net (Yandex) with ESMTPS id 8C9B260E1D; Thu, 7 Nov 2024 17:50:07 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-60.sas.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id OnjeqGHSqKo0-hO83VaWO; Thu, 07 Nov 2024 17:50:06 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tantorlabs.com; s=mail; t=1730991006; bh=g/ftbbb5PHlot98YOfbzUIJZV49gGyeoEDEu5CCDA2w=; h=In-Reply-To:Cc:Date:References:To:Subject:Message-ID:From; b=qPBtg5oA4qxmw0PMkn9HgPRzhaMng8jFXRJHkz3OXUB7maIHC2taZV7V56k55B87C HEDnkfHRnXEySZdAGGQgI8krH+Q7FH6X3zQebjoNroPojZvQEzfiPmSU9Zdf4ma+eH KGsz2SlfTaPoMgqyJ61gqcC6IkFm0rbjIRVg1zZE= Authentication-Results: mail-nwsmtp-smtp-production-main-60.sas.yp-c.yandex.net; dkim=pass header.i=@tantorlabs.com Content-Type: multipart/alternative; boundary="------------t3iQk71I4TiklzNgzFlIt6Ra" Message-ID: <52ca6a89-d19d-4df9-ac4b-95548500bf8b@tantorlabs.com> Date: Thu, 7 Nov 2024 17:49:23 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Vacuum statistics To: Alena Rybakina , pgsql-hackers Cc: jian he , Alexander Korotkov , Andrei Zubkov , Alena Rybakina , a.lepikhov@postgrespro.ru References: <53c47c2d-72a5-44f2-900c-9973b2af1808@tantorlabs.com> <4a902cea-54fb-41b5-b208-b84731a5f577@postgrespro.ru> <092adec6-4eae-4bd4-bd0d-473a9df1282b@tantorlabs.com> <3deae1bd-ad84-4459-a26e-04c9136b84e9@postgrespro.ru> <9b10c6d3-52c4-4eef-b67c-c33442667729@postgrespro.ru> <30e2e941-b9f6-4ea1-aa3b-f0c406b8797d@postgrespro.ru> <1a960398-d12d-419a-af48-4acfe58d0c3a@tantorlabs.com> <8b2f3c20-02ac-4658-b78f-e9d7590f893b@postgrespro.ru> <995657bc-9966-47c0-b085-4c5e8886d249@postgrespro.ru> Content-Language: en-US From: Ilia Evdokimov In-Reply-To: <995657bc-9966-47c0-b085-4c5e8886d249@postgrespro.ru> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------t3iQk71I4TiklzNgzFlIt6Ra Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 22.10.2024 22:30, Alena Rybakina wrote: > > 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 Thank you for fixing it. 1) I have found some typos in the test output files (out-files) when running 'make check' and 'make check-world'. These typos might cause minor discrepancies in test results. You may already be aware of them, but I wanted to bring them to your attention in case they haven't been noticed. I believe these can be fixed quickly. 2) Additionally, I observed that when we create a table and insert some rows, executing the VACUUM FULL command does not update the information in the 'pg_stat_get_vacuum_tables' However, running the VACUUM command does update this information as expected. This seems inconsistent, and it might be a bug. Example: CREATE TABLE t (i INT, j INT) WITH (autovacuum_enabled = false); INSERT INTO t SELECT i/10, i/100 FROM  GENERATE_SERIES(1,1000000) i; SELECT * FROM pg_stat_get_vacuum_tables WHERE relname = 't'; schema | relname |    relid | total_blks_read | ......... -----------+------------+---------+----------------------+---------    public | t            | 21416 |                       0 | ...... (1 row) VACUUM FULL; SELECT * FROM pg_stat_get_vacuum_tables WHERE relname = 't'; schema | relname |    relid | total_blks_read | ......... -----------+------------+---------+----------------------+---------    public | t            | 21416 |                       0 | ...... (1 row) VACUUM; SELECT * FROM pg_stat_get_vacuum_tables WHERE relname = 't'; schema | relname |    relid | total_blks_read | ......... -----------+------------+---------+----------------------+---------    public | t            | 21416 |                 4425 | ...... (1 row) Regards, Ilia Evdokimov, Tantor Labs LLC. --------------t3iQk71I4TiklzNgzFlIt6Ra Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit


On 22.10.2024 22:30, Alena Rybakina wrote:

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_databaseS  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

Thank you for fixing it.

1) I have found some typos in the test output files (out-files) when running 'make check' and 'make check-world'. These typos might cause minor discrepancies in test results. You may already be aware of them, but I wanted to bring them to your attention in case they haven't been noticed. I believe these can be fixed quickly.

2) Additionally, I observed that when we create a table and insert some rows, executing the VACUUM FULL command does not update the information in the 'pg_stat_get_vacuum_tables' However, running the VACUUM command does update this information as expected. This seems inconsistent, and it might be a bug.

Example:
CREATE TABLE t (i INT, j INT) WITH (autovacuum_enabled = false);
INSERT INTO t SELECT i/10, i/100 FROM  GENERATE_SERIES(1,1000000) i;
SELECT * FROM pg_stat_get_vacuum_tables WHERE relname = 't';
schema | relname |    relid | total_blks_read | .........
-----------+------------+---------+----------------------+---------
   public | t            | 21416 |                       0 | ......
(1 row)

VACUUM FULL;
SELECT * FROM pg_stat_get_vacuum_tables WHERE relname = 't';
schema | relname |    relid | total_blks_read | .........
-----------+------------+---------+----------------------+---------
   public | t            | 21416 |                       0 | ......
(1 row)

VACUUM;
SELECT * FROM pg_stat_get_vacuum_tables WHERE relname = 't';
schema | relname |    relid | total_blks_read | .........
-----------+------------+---------+----------------------+---------
   public | t            | 21416 |                 4425 | ......
(1 row)

Regards,
Ilia Evdokimov,
Tantor Labs LLC.

--------------t3iQk71I4TiklzNgzFlIt6Ra--