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 1tTRYQ-005jdb-4I for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Jan 2025 20:12:26 +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 1tTRYO-0017EX-Pe for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Jan 2025 20:12:24 +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 1tTRYO-0017EO-G9 for pgsql-hackers@lists.postgresql.org; Thu, 02 Jan 2025 20:12:24 +0000 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tTRYL-002sQT-7W for pgsql-hackers@postgresql.org; Thu, 02 Jan 2025 20:12:23 +0000 Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-304d757a9c1so6967841fa.0 for ; Thu, 02 Jan 2025 12:12:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735848740; x=1736453540; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=gFwmIotIqvVdp1K3qndc7A924jTBmAYynWmcyjkF1f8=; b=Kn223UcI6l+p0Bgh0uX+YTHKPA0Mb4JdITGmvxxmhPoM/hsQ1T1XYAsxOWSLzOVUb8 2QWFxCleBe9F0BTml4b24Gy6ZdENaXQzeKcH8iSLpt3AsQuIOqHNt9hRvyOQSssKCVf6 Oft6zBc4JG/0qVVZbBGWL9f0JzPY0tFxca1eN6F/Q4HDLKVSbAM5pauv4Oak2/1LFlxy djTXq5spbZEHrC968a8YBoiyWzwu4a96Fp/HqSk3WCEm503SdPZm7W4bw25wunIFZ4jx 9ivbQ3XS3kdG3q38JxCeoG55Mm6fwcwcVf5sSkkhTsrv9c3qn43ex02Sw1tfLMhFLlNj NfMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735848740; x=1736453540; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gFwmIotIqvVdp1K3qndc7A924jTBmAYynWmcyjkF1f8=; b=et+X92Ico81HD+fUzq1h5Kky2+6de37hgzDCALG2lOHObzSQTkwXIkBG1i5G58eiw8 282yCe02sXQpuszSfGy7sHdik9ufKj05dwxpv3DSOQbMDsEOsQ4+Rv+qFKqtPpCWabi/ 7emRNTqZVDkHnu5qHyvvKfEYnFyLsXMi1YeJajGQMWTdI1FKXbDFSc5PZncWiPP1kKQJ k9nwp35lUf8VxjRMEfWr2G79sAxAp4D3MucOzelt9XuMW7uWc6rU2SQ2QR9LevQDyFes QrB2tuDNSDIZFxSpVwFO4IYUTP6p+tkvcrx+o5LfaN4vQ7AuFbYLUW3Gu2xWeFh3QpDw oedQ== X-Forwarded-Encrypted: i=1; AJvYcCWAEQ1uy5jCeIywe1CYWWGT+DeGzPeMLDP64CdMlVHzihi85/Ij7qnVdNx6UVnYiI/21c3uDnaYifW55nYB@postgresql.org X-Gm-Message-State: AOJu0YyRtMM+GFDkcFUtcVoATJ2jTaz59PGi0FBtE28odxe0sooF4UKw 4uzMo7OqOuy7L2YffjMhMWdrY/MpLoKQRCkyAhd7bXS1VG/j0eNrhf9E9E1qLCneeZvW2sUxLRS UHkB3Kadloi9jVcltNI//tOOEVP8= X-Gm-Gg: ASbGnct5acek+Ep2hXTl4XDY7Z9jKSSVMobmu/Cb9oDeauOK/bYoD9r3Y6braAY3GyM 32CZP/FO6QxaSnk3h+iAm+s0O3ZqxtpGESN6c X-Google-Smtp-Source: AGHT+IHgyrUPownpT6bP3QaHXT6rlweTFbcziKEVzyTw0p0aQmoJapUumtevGbNHwvyxdlJtX2a7QsbKgFvZFAqUqpk= X-Received: by 2002:a05:651c:b24:b0:302:49f7:1d72 with SMTP id 38308e7fff4ca-30469b34be9mr153376521fa.9.1735848740097; Thu, 02 Jan 2025 12:12:20 -0800 (PST) MIME-Version: 1.0 References: <9b10c6d3-52c4-4eef-b67c-c33442667729@postgrespro.ru> <9485d892-fd04-4e3a-ac24-7dd767cb7333@postgrespro.ru> <0B6CBF4C-CC2A-4200-9126-CE3A390D938B@upgrade.com> <6732acf8ce0f31025b535ae1a64568750924a887.camel@moonset.ru> <5AA8FFD5-6DE2-4A31-8E00-AE98F738F5D1@upgrade.com> <85b963fe-5977-43aa-9241-75b862abcc69@postgrespro.ru> <9C7A167C-DCDE-4A17-9ABE-6276723FEC50@upgrade.com> <2d493cf9-9ba7-4cc1-a3f2-67afd7c163ee@postgrespro.ru> <77e6e723-0d3e-4235-8386-03d143916125@postgrespro.ru> In-Reply-To: <77e6e723-0d3e-4235-8386-03d143916125@postgrespro.ru> From: Sami Imseih Date: Thu, 2 Jan 2025 14:12:08 -0600 Message-ID: Subject: Re: Vacuum statistics To: Alena Rybakina Cc: Ilia Evdokimov , Jim Nasby , Andrei Zubkov , Masahiko Sawada , Melanie Plageman , jian he , pgsql-hackers , a.lepikhov@postgrespro.ru, Alexander Korotkov Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, Thanks for the work you have done here. Exposing cumulative metrics at this level of detail for vacuum is surely useful to find vacuum bottlenecks and to determine the effectiveness of vacuum tuning. I am yet to look very closely, but I think some additional columns that will be useful is the number of failsafe autovacuums occurred. Also the counter for number of index_cleanup skipped, truncate phase skipped and toast vacuuming skipped ( the latter will only be relevant for the main relation ). I also wonder if if makes sense to break down timing by phase. I surely would like to know how much of my vacuum time was spent in index cleanup vs heap scan, etc. A nit: I noticed in v14, the column is "schema". It should be "schemaname" for consistency. Also, instead of pg_stat_vacuum_tables, what about pg_stat_vacuum? Now, I became aware of this discussion after starting a new thread to track total time spent in vacuum/analyze in pg_stat_all_tables [1]. But this begs the question of what should be done with the current counters in pg_stat_all_tables? I see it mentioned above that (auto)vacuum_count should be added to this new view, but it's also already in pg_stat_all_tables. I don't think we should be duplicating the same columns across views. I think total_time should be removed from your current patch and added as is being suggested in [1]. This way high level metrics such as counts and total time spent remain in pg_stat_all_tables, while the new view you are proposing will contain more details. I don't think we will have consistency issues between the views because a reset using pg_stat_reset() will act on all the stats and pg_stat_reset_single_table_counters() will act on all the stats related to that table. There should be no way to reset the vacuum stats independently, AFAICT. Alternatively, we can remove the vacuum related stats from pg_stat_all_tables, but that will break monitoring tools and will leave us with the (auto)analyze metrics alone in pg_stat_all_tables. This sounds very ugly. What do you think? Regards, Sami Imseih Amazon Web Services (AWS) [1] https://commitfest.postgresql.org/52/5485/