On Wed, Feb 12, 2025 at 06:19:12AM +0000, Bertrand Drouvot wrote: > Thanks! Regarding 0003 I think it's ok to keep it in this thread (and not > create a dedicated one), as it still fits well with $SUBJECT (and the folks > interested in are probably already part of this thread). Sounds good to you?
Yup. Here is what I have staged for commit. I'll create a commifest entry for this one and give it a couple days for review, but this seems pretty straightforward. -- nathan
>From 3853d2e72a2f3d2de43080482450922ebb715c37 Mon Sep 17 00:00:00 2001 From: Nathan Bossart <nat...@postgresql.org> Date: Wed, 12 Feb 2025 11:03:56 -0600 Subject: [PATCH v18 1/1] Add delay time to VACUUM/ANALYZE (VERBOSE) and autovacuum logs. Commit bb8dff9995 added this information to the pg_stat_progress_vacuum and pg_stat_progress_analyze system views. This commit adds the same information to the output of VACUUM and ANALYZE with the VERBOSE option and to the autovacuum logs. Author: Bertrand Drouvot <bertranddrouvot...@gmail.com> Discussion: https://postgr.es/m/ZmaXmWDL829fzAVX%40ip-10-97-1-34.eu-west-3.compute.internal --- doc/src/sgml/config.sgml | 9 ++++++--- src/backend/access/heap/vacuumlazy.c | 3 +++ src/backend/commands/analyze.c | 3 +++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 5e4f201e099..60829b79d83 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -8267,9 +8267,12 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv; platforms. You can use the <xref linkend="pgtesttiming"/> tool to measure the overhead of timing on your system. Cost-based vacuum delay timing information is displayed in - <link linkend="vacuum-progress-reporting"><structname>pg_stat_progress_vacuum</structname></link> - and - <link linkend="analyze-progress-reporting"><structname>pg_stat_progress_analyze</structname></link>. + <link linkend="vacuum-progress-reporting"><structname>pg_stat_progress_vacuum</structname></link>, + <link linkend="analyze-progress-reporting"><structname>pg_stat_progress_analyze</structname></link>, + in the output of <xref linkend="sql-vacuum"/> when the + <literal>VERBOSE</literal> option is used, and by autovacuum for + auto-vacuums and auto-analyzes when + <xref linkend="guc-log-autovacuum-min-duration"/> is set. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. </para> diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c index 3df5b92afb8..a7016185476 100644 --- a/src/backend/access/heap/vacuumlazy.c +++ b/src/backend/access/heap/vacuumlazy.c @@ -1083,6 +1083,9 @@ heap_vacuum_rel(Relation rel, VacuumParams *params, istat->pages_deleted, istat->pages_free); } + if (track_cost_delay_timing) + appendStringInfo(&buf, _("cost delay time: %.3f ms\n"), + (double) MyBEEntry->st_progress_param[PROGRESS_VACUUM_DELAY_TIME] / 1000000.0); if (track_io_timing) { double read_ms = (double) (pgStatBlockReadTime - startreadtime) / 1000; diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index e4302f4cdb2..1a94eac6381 100644 --- a/src/backend/commands/analyze.c +++ b/src/backend/commands/analyze.c @@ -808,6 +808,9 @@ do_analyze_rel(Relation onerel, VacuumParams *params, get_database_name(MyDatabaseId), get_namespace_name(RelationGetNamespace(onerel)), RelationGetRelationName(onerel)); + if (track_cost_delay_timing) + appendStringInfo(&buf, _("cost delay time: %.3f ms\n"), + (double) MyBEEntry->st_progress_param[PROGRESS_ANALYZE_DELAY_TIME] / 1000000.0); if (track_io_timing) { double read_ms = (double) (pgStatBlockReadTime - startreadtime) / 1000; -- 2.39.5 (Apple Git-154)