Re: Track skipped tables during autovacuum and autoanalyze
| От | Yugo Nagata |
|---|---|
| Тема | Re: Track skipped tables during autovacuum and autoanalyze |
| Дата | |
| Msg-id | 20260326192203.e6dbb8d80f8d27dc15ceee59@sraoss.co.jp обсуждение |
| Ответ на | Re: Track skipped tables during autovacuum and autoanalyze (Yugo Nagata <nagata@sraoss.co.jp>) |
| Ответы |
Re: Track skipped tables during autovacuum and autoanalyze
|
| Список | pgsql-hackers |
> On Tue, 24 Mar 2026 09:58:48 -0500 > Sami Imseih <samimseih@gmail.com> wrote: > > 1/ > > > > + if (AmAutoVacuumWorkerProcess()) > > + pgstat_report_skipped_vacuum(relid); > > > > Any reason why this should not also include manual vacuum/analyze? > > If someone has a vacuum/analyze script that uses SKIP_LOCKED, and > > the operation gets skipped, this should be included in the counter. > > this can be done with separate counter fields for autovacuum/autoanalyze and > > vacuum/analyze > > For manual vacuum/analyze, an explicit WARNING is output when the > operation is skipped, so I initially thought that reporting it in the > stats view was not necessary. However, I now agree that it should be > included. I've attached an updated patch to also report skipped manual vacuum/analyze. The pgstat reporting functions are unified into a single function, pgstat_report_skipped_vacuum_analyze(), which handles both auto/manual and vacuum/analyze cases. Also it is fixed to use InvalidOid for shared relations. To support manual vacuum/analyze, some hack were needed to obtain the relid before the lock attempt. When SKIP_LOCKED is specified, the relid is obtained using RangeVarGetRelid() with NoLock prior to locking. If ConditionalLockRelationOid() then fails, the skip is reported. To handle the possibility that the table is dropped between RangeVarGetRelid() and the lock attempt, SearchSysCacheExists1() is used after acquiring the lock. Regards, Yugo Nagata -- Yugo Nagata <nagata@sraoss.co.jp>
Вложения
В списке pgsql-hackers по дате отправления: