mirror of
https://github.com/postgres/postgres.git
synced 2025-12-19 17:02:53 +03:00
Add started_by column to pg_stat_progress_analyze view.
The new column, started_by, indicates the initiator of the
analyze ('manual' or 'autovacuum'), helping users and monitoring tools
to better understand ANALYZE behavior.
Bump catalog version.
Author: Shinya Kato <shinya11.kato@gmail.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Sami Imseih <samimseih@gmail.com>
Reviewed-by: Yu Wang <wangyu_runtime@163.com>
Discussion: https://postgr.es/m/CAA5RZ0suoicwxFeK_eDkUrzF7s0BVTaE7M%2BehCpYcCk5wiECpw%40mail.gmail.com
This commit is contained in:
@@ -5770,6 +5770,31 @@ FROM pg_stat_get_backend_idset() AS backendid;
|
|||||||
zero).
|
zero).
|
||||||
</para></entry>
|
</para></entry>
|
||||||
</row>
|
</row>
|
||||||
|
|
||||||
|
<row>
|
||||||
|
<entry role="catalog_table_entry"><para role="column_definition">
|
||||||
|
<structfield>started_by</structfield> <type>text</type>
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
Shows what caused the current <command>ANALYZE</command> operation to be
|
||||||
|
started. Possible values are:
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
<literal>manual</literal>: The analyze was started by an explicit
|
||||||
|
<command>ANALYZE</command>, or by <command>VACUUM</command> with
|
||||||
|
the <option>ANALYZE</option> option.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
<literal>autovacuum</literal>: The analyze was started by an
|
||||||
|
autovacuum worker.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
</para></entry>
|
||||||
|
</row>
|
||||||
</tbody>
|
</tbody>
|
||||||
</tgroup>
|
</tgroup>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -1247,7 +1247,10 @@ CREATE VIEW pg_stat_progress_analyze AS
|
|||||||
S.param6 AS child_tables_total,
|
S.param6 AS child_tables_total,
|
||||||
S.param7 AS child_tables_done,
|
S.param7 AS child_tables_done,
|
||||||
CAST(S.param8 AS oid) AS current_child_table_relid,
|
CAST(S.param8 AS oid) AS current_child_table_relid,
|
||||||
S.param9 / 1000000::double precision AS delay_time
|
S.param9 / 1000000::double precision AS delay_time,
|
||||||
|
CASE S.param10 WHEN 1 THEN 'manual'
|
||||||
|
WHEN 2 THEN 'autovacuum'
|
||||||
|
ELSE NULL END AS started_by
|
||||||
FROM pg_stat_get_progress_info('ANALYZE') AS S
|
FROM pg_stat_get_progress_info('ANALYZE') AS S
|
||||||
LEFT JOIN pg_database D ON S.datid = D.oid;
|
LEFT JOIN pg_database D ON S.datid = D.oid;
|
||||||
|
|
||||||
|
|||||||
@@ -239,6 +239,12 @@ analyze_rel(Oid relid, RangeVar *relation,
|
|||||||
*/
|
*/
|
||||||
pgstat_progress_start_command(PROGRESS_COMMAND_ANALYZE,
|
pgstat_progress_start_command(PROGRESS_COMMAND_ANALYZE,
|
||||||
RelationGetRelid(onerel));
|
RelationGetRelid(onerel));
|
||||||
|
if (AmAutoVacuumWorkerProcess())
|
||||||
|
pgstat_progress_update_param(PROGRESS_ANALYZE_STARTED_BY,
|
||||||
|
PROGRESS_ANALYZE_STARTED_BY_AUTOVACUUM);
|
||||||
|
else
|
||||||
|
pgstat_progress_update_param(PROGRESS_ANALYZE_STARTED_BY,
|
||||||
|
PROGRESS_ANALYZE_STARTED_BY_MANUAL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Do the normal non-recursive ANALYZE. We can skip this for partitioned
|
* Do the normal non-recursive ANALYZE. We can skip this for partitioned
|
||||||
|
|||||||
@@ -57,6 +57,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* yyyymmddN */
|
/* yyyymmddN */
|
||||||
#define CATALOG_VERSION_NO 202512092
|
#define CATALOG_VERSION_NO 202512093
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -60,6 +60,7 @@
|
|||||||
#define PROGRESS_ANALYZE_CHILD_TABLES_DONE 6
|
#define PROGRESS_ANALYZE_CHILD_TABLES_DONE 6
|
||||||
#define PROGRESS_ANALYZE_CURRENT_CHILD_TABLE_RELID 7
|
#define PROGRESS_ANALYZE_CURRENT_CHILD_TABLE_RELID 7
|
||||||
#define PROGRESS_ANALYZE_DELAY_TIME 8
|
#define PROGRESS_ANALYZE_DELAY_TIME 8
|
||||||
|
#define PROGRESS_ANALYZE_STARTED_BY 9
|
||||||
|
|
||||||
/* Phases of analyze (as advertised via PROGRESS_ANALYZE_PHASE) */
|
/* Phases of analyze (as advertised via PROGRESS_ANALYZE_PHASE) */
|
||||||
#define PROGRESS_ANALYZE_PHASE_ACQUIRE_SAMPLE_ROWS 1
|
#define PROGRESS_ANALYZE_PHASE_ACQUIRE_SAMPLE_ROWS 1
|
||||||
@@ -68,6 +69,10 @@
|
|||||||
#define PROGRESS_ANALYZE_PHASE_COMPUTE_EXT_STATS 4
|
#define PROGRESS_ANALYZE_PHASE_COMPUTE_EXT_STATS 4
|
||||||
#define PROGRESS_ANALYZE_PHASE_FINALIZE_ANALYZE 5
|
#define PROGRESS_ANALYZE_PHASE_FINALIZE_ANALYZE 5
|
||||||
|
|
||||||
|
/* Reasons for analyze (as advertised via PROGRESS_ANALYZE_STARTED_BY) */
|
||||||
|
#define PROGRESS_ANALYZE_STARTED_BY_MANUAL 1
|
||||||
|
#define PROGRESS_ANALYZE_STARTED_BY_AUTOVACUUM 2
|
||||||
|
|
||||||
/* Progress parameters for cluster */
|
/* Progress parameters for cluster */
|
||||||
#define PROGRESS_CLUSTER_COMMAND 0
|
#define PROGRESS_CLUSTER_COMMAND 0
|
||||||
#define PROGRESS_CLUSTER_PHASE 1
|
#define PROGRESS_CLUSTER_PHASE 1
|
||||||
|
|||||||
@@ -1969,7 +1969,12 @@ pg_stat_progress_analyze| SELECT s.pid,
|
|||||||
s.param6 AS child_tables_total,
|
s.param6 AS child_tables_total,
|
||||||
s.param7 AS child_tables_done,
|
s.param7 AS child_tables_done,
|
||||||
(s.param8)::oid AS current_child_table_relid,
|
(s.param8)::oid AS current_child_table_relid,
|
||||||
((s.param9)::double precision / (1000000)::double precision) AS delay_time
|
((s.param9)::double precision / (1000000)::double precision) AS delay_time,
|
||||||
|
CASE s.param10
|
||||||
|
WHEN 1 THEN 'manual'::text
|
||||||
|
WHEN 2 THEN 'autovacuum'::text
|
||||||
|
ELSE NULL::text
|
||||||
|
END AS started_by
|
||||||
FROM (pg_stat_get_progress_info('ANALYZE'::text) s(pid, datid, relid, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15, param16, param17, param18, param19, param20)
|
FROM (pg_stat_get_progress_info('ANALYZE'::text) s(pid, datid, relid, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15, param16, param17, param18, param19, param20)
|
||||||
LEFT JOIN pg_database d ON ((s.datid = d.oid)));
|
LEFT JOIN pg_database d ON ((s.datid = d.oid)));
|
||||||
pg_stat_progress_basebackup| SELECT pid,
|
pg_stat_progress_basebackup| SELECT pid,
|
||||||
|
|||||||
Reference in New Issue
Block a user