Re: POC: track vacuum/analyze cumulative time per relation

From: Sami Imseih <samimseih(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: POC: track vacuum/analyze cumulative time per relation
Date: 2025-01-20 17:04:40
Message-ID: CAA5RZ0su2Unc+iJkhL6QEfsbjj6-WXjRWyf2E0b4BotUH=o4FA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> I can get behind the idea of the patch.

Thanks for the review!

> + PgStat_Counter total_vacuum_time;
> + PgStat_Counter total_autovacuum_time;
> + PgStat_Counter total_analyze_time;
> + PgStat_Counter total_autoanalyze_time;
> } PgStat_StatTabEntry;
> These are time values in milliseconds. It would be good to document
> that as a comment with these fields, like PgStat_CheckpointerStats and
> others. Perhaps they should be grouped with their related counters
> within PgStat_StatTabEntry? Or not.

done, including grouping all the vacuum counters together.

> This is incorrect, endtime is never set.

indeed. fixed.

> I would give priority to the
> symmetry of the code here, using for the analyze reporting the same
> arguments as the vacuum bits, so as we don't call GetCurrentTimestamp
> in the proposed changes for pgstat_report_analyze().

I agree.
pgstat_report_analyze and pgstat_report_vacuum match
will now take endtime and elapsedtime and we can remove
the GetCurrentTimestamp inside pgstat_report_analyze.

> + if (AmAutoVacuumWorkerProcess())
> + tabentry->total_autovacuum_time += elapsedtime;
> + else
> + tabentry->total_vacuum_time += elapsedtime;
> [...]
> + if (AmAutoVacuumWorkerProcess())
> + tabentry->total_autoanalyze_time += elapsedtime;
> + else
> + tabentry->total_analyze_time += elapsedtime;
>

Correct. fixed as well.

See the attached v6.

Thanks!

Regards,

Sami

Attachment Content-Type Size
v6-0001-Track-per-relation-cumulative-time-spent-in-vacuu.patch application/octet-stream 16.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2025-01-20 17:06:58 Re: Proper way to clean-up connection for reuse (`DISCARD ALL` and default role)
Previous Message Nathan Bossart 2025-01-20 17:02:56 Re: Purpose of wal_init_zero