You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudberry.apache.org by ma...@apache.org on 2025/09/08 07:20:38 UTC
(cloudberry) branch main updated (b8a78af7f42 -> 05869c862a5)
This is an automated email from the ASF dual-hosted git repository.
maxyang pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git
from b8a78af7f42 Fix: quick exit in dumptuples if query execution is finished
new 5142c0e8afe Fix names of pg_stat_all_tables|indexes
new 86306e03363 Add gp_stat_progress_%_summary system views
new 2b1c9c306ea Add gp summary system views
new 05869c862a5 Fix: Adapt system view after cherry-pick
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
configure.ac | 2 +-
.../expected/auto_explain_optimizer.out | 2 +-
.../isolation2/input/autovacuum-analyze.source | 12 +-
.../isolation2/output/autovacuum-analyze.source | 12 +-
.../src/test/regress/expected/pg_stat.out | 16 +-
.../src/test/regress/expected/stats.out | 14 +-
.../test/regress/input/pgstat_qd_tabstat.source | 80 ++--
.../test/regress/output/pgstat_qd_tabstat.source | 84 ++--
.../pax_storage/src/test/regress/sql/pg_stat.sql | 16 +-
contrib/pax_storage/src/test/regress/sql/stats.sql | 14 +-
src/backend/catalog/Makefile | 3 +-
src/backend/catalog/system_views.sql | 149 +-----
src/backend/catalog/system_views_gp.in | 22 +-
src/backend/catalog/system_views_gp_summary.sql | 491 ++++++++++++++++++++
src/backend/commands/analyze.c | 1 +
src/bin/initdb/initdb.c | 6 +-
src/include/catalog/catversion.h | 2 +-
src/test/isolation2/expected/analyze_progress.out | 94 ++++
.../expected/ao_index_build_progress.out | 86 +++-
.../isolation2/expected/vacuum_progress_column.out | 83 ++--
.../isolation2/expected/vacuum_progress_row.out | 506 ++++++++++++++-------
.../isolation2/input/autovacuum-analyze.source | 12 +-
src/test/isolation2/isolation2_schedule | 1 +
.../isolation2/output/autovacuum-analyze.source | 12 +-
.../output/parallel_retrieve_cursor/explain.source | 19 +-
src/test/isolation2/sql/analyze_progress.sql | 42 ++
.../isolation2/sql/ao_index_build_progress.sql | 44 +-
src/test/isolation2/sql/vacuum_progress_column.sql | 21 +-
src/test/isolation2/sql/vacuum_progress_row.sql | 248 +++++-----
src/test/regress/expected/pg_stat.out | 16 +-
src/test/regress/expected/stats.out | 14 +-
src/test/regress/input/pgstat_qd_tabstat.source | 80 ++--
src/test/regress/output/pgstat_qd_tabstat.source | 84 ++--
src/test/regress/sql/pg_stat.sql | 16 +-
src/test/regress/sql/stats.sql | 14 +-
35 files changed, 1498 insertions(+), 820 deletions(-)
create mode 100644 src/backend/catalog/system_views_gp_summary.sql
create mode 100644 src/test/isolation2/expected/analyze_progress.out
create mode 100644 src/test/isolation2/sql/analyze_progress.sql
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org
(cloudberry) 02/04: Add gp_stat_progress_%_summary system views
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
maxyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git
commit 86306e03363f49c20204bb1be670ec7fac4c53dc
Author: Alexandra Wang <wa...@vmware.com>
AuthorDate: Thu Apr 27 16:53:32 2023 -0700
Add gp_stat_progress_%_summary system views
Added the following views:
gp_stat_progress_vacuum_summary
gp_stat_progress_analyze_summary
gp_stat_progress_cluster_summary
gp_stat_progress_create_index_summary
Also replaced pg_stat_progress_* views with gp_stat_progress_* views for
existing tests.
---
src/backend/catalog/Makefile | 3 +-
src/backend/catalog/system_views_gp_summary.sql | 109 ++++++++++++
src/backend/commands/analyze.c | 1 +
src/bin/initdb/initdb.c | 6 +-
src/include/catalog/catversion.h | 2 +-
src/test/isolation2/expected/analyze_progress.out | 95 +++++++++++
.../expected/ao_index_build_progress.out | 88 +++++++---
.../isolation2/expected/vacuum_progress_row.out | 189 +++++++++++++--------
src/test/isolation2/isolation2_schedule | 1 +
src/test/isolation2/sql/analyze_progress.sql | 42 +++++
.../isolation2/sql/ao_index_build_progress.sql | 44 +++--
src/test/isolation2/sql/setup.sql | 21 +++
src/test/isolation2/sql/vacuum_progress_row.sql | 168 +++++-------------
13 files changed, 538 insertions(+), 231 deletions(-)
diff --git a/src/backend/catalog/Makefile b/src/backend/catalog/Makefile
index 260bd608d50..f1a0251e1cb 100644
--- a/src/backend/catalog/Makefile
+++ b/src/backend/catalog/Makefile
@@ -201,6 +201,7 @@ endif
$(INSTALL_DATA) $(srcdir)/system_functions.sql '$(DESTDIR)$(datadir)/system_functions.sql'
$(INSTALL_DATA) $(srcdir)/system_views.sql '$(DESTDIR)$(datadir)/system_views.sql'
$(INSTALL_DATA) $(srcdir)/$(GP_SYSVIEW_SQL) '$(DESTDIR)$(datadir)/$(GP_SYSVIEW_SQL)'
+ $(INSTALL_DATA) $(srcdir)/system_views_gp_summary.sql '$(DESTDIR)$(datadir)/system_views_gp_summary.sql'
$(INSTALL_DATA) $(srcdir)/information_schema.sql '$(DESTDIR)$(datadir)/information_schema.sql'
$(INSTALL_DATA) $(call vpathsearch,cdb_schema.sql) '$(DESTDIR)$(datadir)/cdb_init.d/cdb_schema.sql'
$(INSTALL_DATA) $(srcdir)/sql_features.txt '$(DESTDIR)$(datadir)/sql_features.txt'
@@ -211,7 +212,7 @@ installdirs:
.PHONY: uninstall-data
uninstall-data:
- rm -f $(addprefix '$(DESTDIR)$(datadir)'/, postgres.bki system_constraints.sql system_functions.sql system_views.sql information_schema.sql cdb_init.d/cdb_schema.sql cdb_init.d/gp_toolkit.sql sql_features.txt)
+ rm -f $(addprefix '$(DESTDIR)$(datadir)'/, postgres.bki system_constraints.sql system_functions.sql system_views.sql system_views_gp_summary.sql information_schema.sql cdb_init.d/cdb_schema.sql cdb_init.d/gp_toolkit.sql sql_features.txt)
ifeq ($(USE_INTERNAL_FTS_FOUND), false)
rm -f $(addprefix '$(DESTDIR)$(datadir)'/, external_fts.sql)
endif
diff --git a/src/backend/catalog/system_views_gp_summary.sql b/src/backend/catalog/system_views_gp_summary.sql
new file mode 100644
index 00000000000..58f4768c124
--- /dev/null
+++ b/src/backend/catalog/system_views_gp_summary.sql
@@ -0,0 +1,109 @@
+/*
+ * Greenplum System Summary Views
+ *
+ * Portions Copyright (c) 2006-2010, Greenplum inc.
+ * Portions Copyright (c) 2012-Present VMware, Inc. or its affiliates.
+ * Copyright (c) 1996-2019, PostgreSQL Global Development Group
+ *
+ * src/backend/catalog/system_views_gp_summary.sql
+ *
+
+ * This file contains summary views for various Greenplum system catalog
+ * views. These summary views are designed to provide aggregated or averaged
+ * information for partitioned and replicated tables, considering multiple
+ * segments in a Greenplum database.
+ *
+ * Note: this file is read in single-user -j mode, which means that the
+ * command terminator is semicolon-newline-newline; whenever the backend
+ * sees that, it stops and executes what it's got. If you write a lot of
+ * statements without empty lines between, they'll all get quoted to you
+ * in any error message about one of them, so don't do that. Also, you
+ * cannot write a semicolon immediately followed by an empty line in a
+ * string literal (including a function body!) or a multiline comment.
+ */
+
+CREATE VIEW gp_stat_progress_vacuum_summary AS
+SELECT
+ max(coalesce(a1.pid, 0)) as pid,
+ a.datid,
+ a.datname,
+ a.relid,
+ a.phase,
+ case when d.policytype = 'r' then (sum(a.heap_blks_total)/d.numsegments)::bigint else sum(a.heap_blks_total) end heap_blks_total,
+ case when d.policytype = 'r' then (sum(a.heap_blks_scanned)/d.numsegments)::bigint else sum(a.heap_blks_scanned) end heap_blks_scanned,
+ case when d.policytype = 'r' then (sum(a.heap_blks_vacuumed)/d.numsegments)::bigint else sum(a.heap_blks_vacuumed) end heap_blks_vacuumed,
+ case when d.policytype = 'r' then (sum(a.index_vacuum_count)/d.numsegments)::bigint else sum(a.index_vacuum_count) end index_vacuum_count,
+ case when d.policytype = 'r' then (sum(a.max_dead_tuples)/d.numsegments)::bigint else sum(a.max_dead_tuples) end max_dead_tuples,
+ case when d.policytype = 'r' then (sum(a.num_dead_tuples)/d.numsegments)::bigint else sum(a.num_dead_tuples) end num_dead_tuples
+FROM gp_stat_progress_vacuum a
+ JOIN pg_class c ON a.relid = c.oid
+ LEFT JOIN gp_distribution_policy d ON c.oid = d.localoid
+ LEFT JOIN gp_stat_progress_vacuum a1 ON a.pid = a1.pid AND a1.gp_segment_id = -1
+WHERE a.gp_segment_id > -1
+GROUP BY a.datid, a.datname, a.relid, a.phase, d.policytype, d.numsegments;
+
+CREATE OR REPLACE VIEW gp_stat_progress_analyze_summary AS
+SELECT
+ max(coalesce(a1.pid, 0)) as pid,
+ a.datid,
+ a.datname,
+ a.relid,
+ a.phase,
+ case when d.policytype = 'r' then (sum(a.sample_blks_total)/d.numsegments)::bigint else sum(a.sample_blks_total) end sample_blks_total,
+ case when d.policytype = 'r' then (sum(a.sample_blks_scanned)/d.numsegments)::bigint else sum(a.sample_blks_scanned) end sample_blks_scanned,
+ case when d.policytype = 'r' then (sum(a.ext_stats_total)/d.numsegments)::bigint else sum(a.ext_stats_total) end ext_stats_total,
+ case when d.policytype = 'r' then (sum(a.ext_stats_computed)/d.numsegments)::bigint else sum(a.ext_stats_computed) end ext_stats_computed,
+ case when d.policytype = 'r' then (sum(a.child_tables_total)/d.numsegments)::bigint else sum(a.child_tables_total) end child_tables_total,
+ case when d.policytype = 'r' then (sum(a.child_tables_done)/d.numsegments)::bigint else sum(a.child_tables_done) end child_tables_done
+FROM gp_stat_progress_analyze a
+ JOIN pg_class c ON a.relid = c.oid
+ LEFT JOIN gp_distribution_policy d ON c.oid = d.localoid
+ LEFT JOIN gp_stat_progress_analyze a1 ON a.pid = a1.pid AND a1.gp_segment_id = -1
+WHERE a.gp_segment_id > -1
+GROUP BY a.datid, a.datname, a.relid, a.phase, d.policytype, d.numsegments;
+
+CREATE OR REPLACE VIEW gp_stat_progress_cluster_summary AS
+SELECT
+ max(coalesce(a1.pid, 0)) as pid,
+ a.datid,
+ a.datname,
+ a.relid,
+ a.command,
+ a.phase,
+ a.cluster_index_relid,
+ case when d.policytype = 'r' then (sum(a.heap_tuples_scanned)/d.numsegments)::bigint else sum(a.heap_tuples_scanned) end heap_tuples_scanned,
+ case when d.policytype = 'r' then (sum(a.heap_tuples_written)/d.numsegments)::bigint else sum(a.heap_tuples_written) end heap_tuples_written,
+ case when d.policytype = 'r' then (sum(a.heap_blks_total)/d.numsegments)::bigint else sum(a.heap_blks_total) end heap_blks_total,
+ case when d.policytype = 'r' then (sum(a.heap_blks_scanned)/d.numsegments)::bigint else sum(a.heap_blks_scanned) end heap_blks_scanned,
+ case when d.policytype = 'r' then (sum(a.index_rebuild_count)/d.numsegments)::bigint else sum(a.index_rebuild_count) end index_rebuild_count
+FROM gp_stat_progress_cluster a
+ JOIN pg_class c ON a.relid = c.oid
+ LEFT JOIN gp_distribution_policy d ON c.oid = d.localoid
+ LEFT JOIN gp_stat_progress_cluster a1 ON a.pid = a1.pid AND a1.gp_segment_id = -1
+WHERE a.gp_segment_id > -1
+GROUP BY a.datid, a.datname, a.relid, a.command, a.phase, a.cluster_index_relid, d.policytype, d.numsegments;
+
+CREATE OR REPLACE VIEW gp_stat_progress_create_index_summary AS
+SELECT
+ max(coalesce(a1.pid, 0)) as pid,
+ a.datid,
+ a.datname,
+ a.relid,
+ a.index_relid,
+ a.command,
+ a.phase,
+ case when d.policytype = 'r' then (sum(a.lockers_total)/d.numsegments)::bigint else sum(a.lockers_total) end lockers_total,
+ case when d.policytype = 'r' then (sum(a.lockers_done)/d.numsegments)::bigint else sum(a.lockers_done) end lockers_done,
+ max(a.current_locker_pid) as current_locker_pid,
+ case when d.policytype = 'r' then (sum(a.blocks_total)/d.numsegments)::bigint else sum(a.blocks_total) end blocks_total,
+ case when d.policytype = 'r' then (sum(a.blocks_done)/d.numsegments)::bigint else sum(a.blocks_done) end blocks_done,
+ case when d.policytype = 'r' then (sum(a.tuples_total)/d.numsegments)::bigint else sum(a.tuples_total) end tuples_total,
+ case when d.policytype = 'r' then (sum(a.tuples_done)/d.numsegments)::bigint else sum(a.tuples_done) end tuples_done,
+ case when d.policytype = 'r' then (sum(a.partitions_total)/d.numsegments)::bigint else sum(a.partitions_total) end partitions_total,
+ case when d.policytype = 'r' then (sum(a.partitions_done)/d.numsegments)::bigint else sum(a.partitions_done) end partitions_done
+FROM gp_stat_progress_create_index a
+ JOIN pg_class c ON a.relid = c.oid
+ LEFT JOIN gp_distribution_policy d ON c.oid = d.localoid
+ LEFT JOIN gp_stat_progress_create_index a1 ON a.pid = a1.pid AND a1.gp_segment_id = -1
+WHERE a.gp_segment_id > -1
+GROUP BY a.datid, a.datname, a.relid, a.index_relid, a.command, a.phase, d.policytype, d.numsegments;
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c
index cfe249d5957..ce642dc84e7 100644
--- a/src/backend/commands/analyze.c
+++ b/src/backend/commands/analyze.c
@@ -1896,6 +1896,7 @@ acquire_sample_rows(Relation onerel, int elevel,
pgstat_progress_update_param(PROGRESS_ANALYZE_BLOCKS_DONE,
++blksdone);
+ SIMPLE_FAULT_INJECTOR("analyze_block");
}
ExecDropSingleTupleTableSlot(slot);
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 8525d0ca0d9..4ed9869a2c9 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -175,6 +175,7 @@ static char *external_fts_files;
static char *system_functions_file;
static char *system_views_file;
static char *system_views_gp_file;
+static char *system_views_gp_summary_file;
static bool success = false;
static bool made_new_pgdata = false;
static bool found_existing_pgdata = false;
@@ -1705,8 +1706,6 @@ setup_run_file(FILE *cmdfd, const char *filename)
}
PG_CMD_PUTS("\n\n");
-
- free(lines);
}
/*
@@ -2833,6 +2832,7 @@ setup_data_file_paths(void)
set_input(&system_functions_file, "system_functions.sql");
set_input(&system_views_file, "system_views.sql");
set_input(&system_views_gp_file, "system_views_gp.sql");
+ set_input(&system_views_gp_summary_file, "system_views_gp_summary.sql");
set_input(&cdb_init_d_dir, "cdb_init.d");
@@ -2867,6 +2867,7 @@ setup_data_file_paths(void)
check_input(system_functions_file);
check_input(system_views_file);
check_input(system_views_gp_file);
+ check_input(system_views_gp_summary_file);
}
@@ -3235,6 +3236,7 @@ initialize_data_directory(void)
setup_run_file(cmdfd, system_views_file);
setup_run_file(cmdfd, system_views_gp_file);
+ setup_run_file(cmdfd, system_views_gp_summary_file);
setup_description(cmdfd);
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 026192b3674..ac649996d98 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -56,6 +56,6 @@
*/
/* 3yyymmddN */
-#define CATALOG_VERSION_NO 302506101
+#define CATALOG_VERSION_NO 302509031
#endif
diff --git a/src/test/isolation2/expected/analyze_progress.out b/src/test/isolation2/expected/analyze_progress.out
new file mode 100644
index 00000000000..97c02fbe617
--- /dev/null
+++ b/src/test/isolation2/expected/analyze_progress.out
@@ -0,0 +1,95 @@
+-- Test gp_stat_progress_analyze_summary
+-- setup hash distributed table
+CREATE TABLE t_analyze_part (a INT, b INT) DISTRIBUTED BY (a);
+CREATE
+INSERT INTO t_analyze_part SELECT i, i FROM generate_series(1, 100000) i;
+INSERT 100000
+
+-- Suspend analyze after scanning 20 blocks on each segment
+SELECT gp_inject_fault('analyze_block', 'suspend', '', '', '', 20, 20, 0, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+ gp_inject_fault
+-----------------
+ Success:
+ Success:
+ Success:
+(3 rows)
+
+-- session 1: analyze the table
+1&: ANALYZE t_analyze_part; <waiting ...>
+SELECT gp_wait_until_triggered_fault('analyze_block', 1, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+ gp_wait_until_triggered_fault
+-------------------------------
+ Success:
+ Success:
+ Success:
+(3 rows)
+
+-- session 2: query pg_stat_progress_analyze while the analyze is running, the view should indicate 60 blocks have been scanned as aggregated progress of 3 segments
+2: SELECT pid IS NOT NULL as has_pid, datname, relid::regclass, phase, sample_blks_total, sample_blks_scanned FROM gp_stat_progress_analyze_summary;
+ has_pid | datname | relid | phase | sample_blks_total | sample_blks_scanned
+---------+----------------+----------------+-----------------------+-------------------+---------------------
+ t | isolation2test | t_analyze_part | acquiring sample rows | 111 | 60
+(1 row)
+
+-- Reset fault injector
+SELECT gp_inject_fault('analyze_block', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+ gp_inject_fault
+-----------------
+ Success:
+ Success:
+ Success:
+(3 rows)
+1<: <... completed>
+ANALYZE
+
+-- teardown
+DROP TABLE t_analyze_part;
+DROP
+
+-- setup replicated table
+CREATE TABLE t_analyze_repl (a INT, b INT) DISTRIBUTED REPLICATED;
+CREATE
+INSERT INTO t_analyze_repl SELECT i, i FROM generate_series(1, 100000) i;
+INSERT 100000
+
+-- Suspend analyze after scanning 20 blocks on each segment
+SELECT gp_inject_fault('analyze_block', 'suspend', '', '', '', 20, 20, 0, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+ gp_inject_fault
+-----------------
+ Success:
+ Success:
+ Success:
+(3 rows)
+
+-- session 1: analyze the table
+1&: ANALYZE t_analyze_repl; <waiting ...>
+SELECT gp_wait_until_triggered_fault('analyze_block', 1, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+ gp_wait_until_triggered_fault
+-------------------------------
+ Success:
+ Success:
+ Success:
+(3 rows)
+
+-- session 2: query pg_stat_progress_analyze while the analyze is running, the view should indicate 20 blocks have been scanned as average progress of 3 segments
+2: SELECT pid IS NOT NULL as has_pid, datname, relid::regclass, phase, sample_blks_total, sample_blks_scanned FROM gp_stat_progress_analyze_summary;
+ has_pid | datname | relid | phase | sample_blks_total | sample_blks_scanned
+---------+----------------+----------------+-----------------------+-------------------+---------------------
+ t | isolation2test | t_analyze_repl | acquiring sample rows | 111 | 20
+(1 row)
+
+-- Reset fault injector
+SELECT gp_inject_fault('analyze_block', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+ gp_inject_fault
+-----------------
+ Success:
+ Success:
+ Success:
+(3 rows)
+1<: <... completed>
+ANALYZE
+
+-- teardown
+DROP TABLE t_analyze_repl;
+DROP
+
diff --git a/src/test/isolation2/expected/ao_index_build_progress.out b/src/test/isolation2/expected/ao_index_build_progress.out
index 1048076ce9f..2cc97d09031 100644
--- a/src/test/isolation2/expected/ao_index_build_progress.out
+++ b/src/test/isolation2/expected/ao_index_build_progress.out
@@ -8,36 +8,52 @@ CREATE
-- Insert all tuples to seg1.
INSERT INTO ao_index_build_progress SELECT 0, i FROM generate_series(1, 100000) i;
INSERT 100000
+INSERT INTO ao_index_build_progress SELECT 2, i FROM generate_series(1, 100000) i;
+INSERT 100000
+INSERT INTO ao_index_build_progress SELECT 5, i FROM generate_series(1, 100000) i;
+INSERT 100000
-- Suspend execution when some blocks have been read.
-SELECT gp_inject_fault('AppendOnlyStorageRead_ReadNextBlock_success', 'suspend', '', '', '', 10, 10, 0, dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+SELECT gp_inject_fault('AppendOnlyStorageRead_ReadNextBlock_success', 'suspend', '', '', '', 10, 10, 0, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
gp_inject_fault
-----------------
Success:
-(1 row)
+ Success:
+ Success:
+(3 rows)
1&: CREATE INDEX ON ao_index_build_progress(i); <waiting ...>
-- Wait until some AO varblocks have been read.
-SELECT gp_wait_until_triggered_fault('AppendOnlyStorageRead_ReadNextBlock_success', 10, dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+SELECT gp_wait_until_triggered_fault('AppendOnlyStorageRead_ReadNextBlock_success', 10, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
gp_wait_until_triggered_fault
-------------------------------
Success:
-(1 row)
+ Success:
+ Success:
+(3 rows)
-- By now, we should have reported some blocks (of size 'block_size') as "done",
-- as well as a total number of blocks that matches the relation's on-disk size.
-1U: SELECT command, phase, (pg_relation_size('ao_index_build_progress') + (current_setting('block_size')::int - 1)) / current_setting('block_size')::int AS blocks_total_actual, blocks_total AS blocks_total_reported, blocks_done AS blocks_done_reported FROM pg_stat_progress_create_index WHERE relid = 'ao_index_build_progress'::regclass;
+SELECT command, phase, (pg_relation_size('ao_index_build_progress') + (current_setting('block_size')::int - 1)) / current_setting('block_size')::int AS blocks_total_actual, blocks_total AS blocks_total_reported, blocks_done AS blocks_done_reported FROM gp_stat_progress_create_index WHERE gp_segment_id = 1 AND relid = 'ao_index_build_progress'::regclass;
command | phase | blocks_total_actual | blocks_total_reported | blocks_done_reported
--------------+--------------------------------+---------------------+-----------------------+----------------------
CREATE INDEX | building index: scanning table | 10 | 10 | 2
(1 row)
+-- The same should be true for the summary view, and the total number of blocks should be tripled.
+SELECT command, phase, blocks_total, blocks_done FROM gp_stat_progress_create_index_summary WHERE relid = 'ao_index_build_progress'::regclass;
+ command | phase | blocks_total | blocks_done
+--------------+--------------------------------+--------------+-------------
+ CREATE INDEX | building index: scanning table | 30 | 6
+(1 row)
-SELECT gp_inject_fault('AppendOnlyStorageRead_ReadNextBlock_success', 'reset', dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+SELECT gp_inject_fault('AppendOnlyStorageRead_ReadNextBlock_success', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
gp_inject_fault
-----------------
Success:
-(1 row)
+ Success:
+ Success:
+(3 rows)
1<: <... completed>
CREATE
@@ -49,38 +65,54 @@ CREATE
-- Insert all tuples to seg1.
INSERT INTO aoco_index_build_progress SELECT 0, i FROM generate_series(1, 100000) i;
INSERT 100000
+INSERT INTO aoco_index_build_progress SELECT 2, i FROM generate_series(1, 100000) i;
+INSERT 100000
+INSERT INTO aoco_index_build_progress SELECT 5, i FROM generate_series(1, 100000) i;
+INSERT 100000
-- Suspend execution when some blocks have been read.
-SELECT gp_inject_fault('AppendOnlyStorageRead_ReadNextBlock_success', 'suspend', '', '', '', 5, 5, 0, dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+SELECT gp_inject_fault('AppendOnlyStorageRead_ReadNextBlock_success', 'suspend', '', '', '', 5, 5, 0, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
gp_inject_fault
-----------------
Success:
-(1 row)
+ Success:
+ Success:
+(3 rows)
1&: CREATE INDEX ON aoco_index_build_progress(i); <waiting ...>
-- Wait until some AOCO varblocks have been read.
-SELECT gp_wait_until_triggered_fault('AppendOnlyStorageRead_ReadNextBlock_success', 5, dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+SELECT gp_wait_until_triggered_fault('AppendOnlyStorageRead_ReadNextBlock_success', 5, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
gp_wait_until_triggered_fault
-------------------------------
Success:
-(1 row)
+ Success:
+ Success:
+(3 rows)
-- By now, we should have reported some blocks (of size 'block_size') as "done",
-- as well as a total number of blocks that matches the relation's on-disk size.
-- Note: all blocks for the relation have to be scanned as we are building an
-- index for the first time and a block directory has to be created.
-1U: SELECT command, phase, (pg_relation_size('aoco_index_build_progress') + (current_setting('block_size')::int - 1)) / current_setting('block_size')::int AS blocks_total_actual, blocks_total AS blocks_total_reported, blocks_done AS blocks_done_reported FROM pg_stat_progress_create_index WHERE relid = 'aoco_index_build_progress'::regclass;
+SELECT command, phase, (pg_relation_size('aoco_index_build_progress') + (current_setting('block_size')::int - 1)) / current_setting('block_size')::int AS blocks_total_actual, blocks_total AS blocks_total_reported, blocks_done AS blocks_done_reported FROM gp_stat_progress_create_index WHERE gp_segment_id = 1 AND relid = 'aoco_index_build_progress'::regclass;
command | phase | blocks_total_actual | blocks_total_reported | blocks_done_reported
--------------+--------------------------------+---------------------+-----------------------+----------------------
CREATE INDEX | building index: scanning table | 20 | 20 | 4
(1 row)
+-- The same should be true for the summary view, and the total number of blocks should be tripled.
+SELECT command, phase, blocks_total, blocks_done FROM gp_stat_progress_create_index_summary WHERE relid = 'aoco_index_build_progress'::regclass;
+ command | phase | blocks_total | blocks_done
+--------------+--------------------------------+--------------+-------------
+ CREATE INDEX | building index: scanning table | 60 | 12
+(1 row)
-SELECT gp_inject_fault('AppendOnlyStorageRead_ReadNextBlock_success', 'reset', dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+SELECT gp_inject_fault('AppendOnlyStorageRead_ReadNextBlock_success', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
gp_inject_fault
-----------------
Success:
-(1 row)
+ Success:
+ Success:
+(3 rows)
1<: <... completed>
CREATE
@@ -88,36 +120,48 @@ CREATE
-- Repeat the test for another index build
-- Suspend execution when some blocks have been read.
-SELECT gp_inject_fault('AppendOnlyStorageRead_ReadNextBlock_success', 'suspend', '', '', '', 5, 5, 0, dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+SELECT gp_inject_fault('AppendOnlyStorageRead_ReadNextBlock_success', 'suspend', '', '', '', 5, 5, 0, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
gp_inject_fault
-----------------
Success:
-(1 row)
+ Success:
+ Success:
+(3 rows)
1&: CREATE INDEX ON aoco_index_build_progress(j); <waiting ...>
-- Wait until some AOCO varblocks have been read.
-SELECT gp_wait_until_triggered_fault('AppendOnlyStorageRead_ReadNextBlock_success', 5, dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+SELECT gp_wait_until_triggered_fault('AppendOnlyStorageRead_ReadNextBlock_success', 5, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
gp_wait_until_triggered_fault
-------------------------------
Success:
-(1 row)
+ Success:
+ Success:
+(3 rows)
-- By now, we should have reported some blocks (of size 'block_size') as "done",
-- as well as a total number of blocks that matches the size of col j's segfile.
-- Note: since we already had a block directory prior to the index build on
--- column 'j', only column 'j' will be scanned. CBDB_CHERRY_PICK_MERGE_FIXME: fix when ao blkdir will be supported
-1U: SELECT command, phase, ((pg_stat_file(pg_relation_filepath('aoco_index_build_progress') || '.' || 129)).size + (current_setting('block_size')::int - 1)) / current_setting('block_size')::int AS col_j_blocks, blocks_total AS blocks_total_reported, blocks_done AS blocks_done_reported FROM pg_stat_progress_create_index WHERE relid = 'aoco_index_build_progress'::regclass;
+-- column 'j', only column 'j' will be scanned.
+1U: SELECT command, phase, ((pg_stat_file(pg_relation_filepath('aoco_index_build_progress') || '.' || 129)).size + (current_setting('block_size')::int - 1)) / current_setting('block_size')::int AS col_j_blocks, blocks_total AS blocks_total_reported, blocks_done AS blocks_done_reported FROM gp_stat_progress_create_index WHERE gp_segment_id = 1 AND relid = 'aoco_index_build_progress'::regclass;
command | phase | col_j_blocks | blocks_total_reported | blocks_done_reported
--------------+--------------------------------+--------------+-----------------------+----------------------
CREATE INDEX | building index: scanning table | 8 | 20 | 4
(1 row)
+-- The same should be true for the summary view, and the total number of blocks should be tripled.
+SELECT command, phase, blocks_total, blocks_done FROM gp_stat_progress_create_index_summary WHERE relid = 'aoco_index_build_progress'::regclass;
+ command | phase | blocks_total | blocks_done
+--------------+--------------------------------+--------------+-------------
+ CREATE INDEX | building index: scanning table | 24 | 9
+(1 row)
-SELECT gp_inject_fault('AppendOnlyStorageRead_ReadNextBlock_success', 'reset', dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+SELECT gp_inject_fault('AppendOnlyStorageRead_ReadNextBlock_success', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
gp_inject_fault
-----------------
Success:
-(1 row)
+ Success:
+ Success:
+(3 rows)
1<: <... completed>
CREATE
diff --git a/src/test/isolation2/expected/vacuum_progress_row.out b/src/test/isolation2/expected/vacuum_progress_row.out
index 0f1b3e65ef5..619b3e41b80 100644
--- a/src/test/isolation2/expected/vacuum_progress_row.out
+++ b/src/test/isolation2/expected/vacuum_progress_row.out
@@ -16,22 +16,21 @@ CREATE
CREATE INDEX on vacuum_progress_ao_row(j);
CREATE
--- Insert all tuples to seg1 from two current sessions so that data are stored
--- in two segment files.
+-- Insert from two current sessions so that data are stored in two segment files.
1: BEGIN;
BEGIN
2: BEGIN;
BEGIN
-1: INSERT INTO vacuum_progress_ao_row SELECT 0, i FROM generate_series(1, 100000) i;
+1: INSERT INTO vacuum_progress_ao_row SELECT i, i FROM generate_series(1, 100000) i;
INSERT 100000
-2: INSERT INTO vacuum_progress_ao_row SELECT 0, i FROM generate_series(1, 100000) i;
+2: INSERT INTO vacuum_progress_ao_row SELECT i, i FROM generate_series(1, 100000) i;
INSERT 100000
-- Commit so that the logical EOF of segno 2 is non-zero.
2: COMMIT;
COMMIT
2: BEGIN;
BEGIN
-2: INSERT INTO vacuum_progress_ao_row SELECT 0, i FROM generate_series(1, 100000) i;
+2: INSERT INTO vacuum_progress_ao_row SELECT i, i FROM generate_series(1, 100000) i;
INSERT 100000
-- Abort so that segno 2 has dead tuples after its logical EOF
2: ABORT;
@@ -53,6 +52,11 @@ SELECT relpages, reltuples, relallvisible FROM pg_class where relname = 'vacuum_
(1 row)
SELECT n_live_tup, n_dead_tup, last_vacuum, vacuum_count FROM pg_stat_all_tables WHERE relname = 'vacuum_progress_ao_row';
n_live_tup | n_dead_tup | last_vacuum | vacuum_count
+------------+------------+-------------+--------------
+ 33327 | 66654 | | 0
+(1 row)
+SELECT n_live_tup, n_dead_tup, last_vacuum, vacuum_count FROM gp_stat_all_tables_summary WHERE relname = 'vacuum_progress_ao_row';
+ n_live_tup | n_dead_tup | last_vacuum | vacuum_count
------------+------------+-------------+--------------
100000 | 200000 | | 0
(1 row)
@@ -60,11 +64,13 @@ SELECT n_live_tup, n_dead_tup, last_vacuum, vacuum_count FROM pg_stat_all_tables
-- Perform VACUUM and observe the progress
-- Suspend execution at pre-cleanup phase after truncating both segfiles to their logical EOF.
-SELECT gp_inject_fault('appendonly_after_truncate_segment_file', 'suspend', '', '', '', 2, 2, 0, dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+SELECT gp_inject_fault('appendonly_after_truncate_segment_file', 'suspend', '', '', '', 2, 2, 0, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
gp_inject_fault
-----------------
Success:
-(1 row)
+ Success:
+ Success:
+(3 rows)
1: set Debug_appendonly_print_compaction to on;
SET
@@ -75,85 +81,120 @@ SELECT gp_wait_until_triggered_fault('appendonly_after_truncate_segment_file', 2
Success:
(1 row)
-- We are in pre_cleanup phase and some blocks should've been vacuumed by now
-1U: select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from pg_stat_progress_vacuum;
+select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id = 1;
relname | phase | heap_blks_total | heap_blks_scanned | heap_blks_vacuumed | index_vacuum_count | max_dead_tuples | num_dead_tuples
------------------------+------------------------------+-----------------+-------------------+--------------------+--------------------+-----------------+-----------------
- vacuum_progress_ao_row | append-optimized pre-cleanup | 165 | 0 | 110 | 0 | 100000 | 0
+ vacuum_progress_ao_row | append-optimized pre-cleanup | 55 | 0 | 37 | 0 | 33327 | 0
+(1 row)
+select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum_summary;
+ relname | phase | heap_blks_total | heap_blks_scanned | heap_blks_vacuumed | index_vacuum_count | max_dead_tuples | num_dead_tuples
+------------------------+------------------------------+-----------------+-------------------+--------------------+--------------------+-----------------+-----------------
+ vacuum_progress_ao_row | append-optimized pre-cleanup | 166 | 0 | 111 | 0 | 100000 | 0
(1 row)
-- Resume execution and suspend again in the middle of compact phase
-SELECT gp_inject_fault('appendonly_insert', 'suspend', '', '', '', 200, 200, 0, dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+SELECT gp_inject_fault('appendonly_insert', 'suspend', '', '', '', 200, 200, 0, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
gp_inject_fault
-----------------
Success:
-(1 row)
-SELECT gp_inject_fault('appendonly_after_truncate_segment_file', 'reset', dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+ Success:
+ Success:
+(3 rows)
+SELECT gp_inject_fault('appendonly_after_truncate_segment_file', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
gp_inject_fault
-----------------
Success:
-(1 row)
+ Success:
+ Success:
+(3 rows)
SELECT gp_wait_until_triggered_fault('appendonly_insert', 200, dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
gp_wait_until_triggered_fault
-------------------------------
Success:
(1 row)
-- We are in compact phase. num_dead_tuples should increase as we move and count tuples, one by one.
-1U: select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from pg_stat_progress_vacuum;
+select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id = 1;
relname | phase | heap_blks_total | heap_blks_scanned | heap_blks_vacuumed | index_vacuum_count | max_dead_tuples | num_dead_tuples
------------------------+--------------------------+-----------------+-------------------+--------------------+--------------------+-----------------+-----------------
- vacuum_progress_ao_row | append-optimized compact | 165 | 0 | 110 | 0 | 100000 | 199
+ vacuum_progress_ao_row | append-optimized compact | 55 | 0 | 37 | 0 | 33327 | 227
+(1 row)
+select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum_summary;
+ relname | phase | heap_blks_total | heap_blks_scanned | heap_blks_vacuumed | index_vacuum_count | max_dead_tuples | num_dead_tuples
+------------------------+--------------------------+-----------------+-------------------+--------------------+--------------------+-----------------+-----------------
+ vacuum_progress_ao_row | append-optimized compact | 166 | 0 | 111 | 0 | 100000 | 594
(1 row)
-- Resume execution and suspend again after compacting all segfiles
-SELECT gp_inject_fault('vacuum_ao_after_compact', 'suspend', dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+SELECT gp_inject_fault('vacuum_ao_after_compact', 'suspend', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
gp_inject_fault
-----------------
Success:
-(1 row)
-SELECT gp_inject_fault('appendonly_insert', 'reset', dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+ Success:
+ Success:
+(3 rows)
+SELECT gp_inject_fault('appendonly_insert', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
gp_inject_fault
-----------------
Success:
-(1 row)
+ Success:
+ Success:
+(3 rows)
SELECT gp_wait_until_triggered_fault('vacuum_ao_after_compact', 1, dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
gp_wait_until_triggered_fault
-------------------------------
Success:
(1 row)
-- After compacting all segfiles we expect 50000 dead tuples
-1U: select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from pg_stat_progress_vacuum;
+select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id = 1;
relname | phase | heap_blks_total | heap_blks_scanned | heap_blks_vacuumed | index_vacuum_count | max_dead_tuples | num_dead_tuples
------------------------+--------------------------+-----------------+-------------------+--------------------+--------------------+-----------------+-----------------
- vacuum_progress_ao_row | append-optimized compact | 165 | 55 | 110 | 0 | 100000 | 50000
+ vacuum_progress_ao_row | append-optimized compact | 55 | 19 | 37 | 0 | 33327 | 16622
+(1 row)
+select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum_summary;
+ relname | phase | heap_blks_total | heap_blks_scanned | heap_blks_vacuumed | index_vacuum_count | max_dead_tuples | num_dead_tuples
+------------------------+--------------------------+-----------------+-------------------+--------------------+--------------------+-----------------+-----------------
+ vacuum_progress_ao_row | append-optimized compact | 166 | 57 | 111 | 0 | 100000 | 50000
(1 row)
-- Resume execution and entering post_cleaup phase, suspend at the end of it.
-SELECT gp_inject_fault('vacuum_ao_post_cleanup_end', 'suspend', dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+SELECT gp_inject_fault('vacuum_ao_post_cleanup_end', 'suspend', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
gp_inject_fault
-----------------
Success:
-(1 row)
-SELECT gp_inject_fault('vacuum_ao_after_compact', 'reset', dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+ Success:
+ Success:
+(3 rows)
+SELECT gp_inject_fault('vacuum_ao_after_compact', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
gp_inject_fault
-----------------
Success:
-(1 row)
+ Success:
+ Success:
+(3 rows)
SELECT gp_wait_until_triggered_fault('vacuum_ao_post_cleanup_end', 1, dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
gp_wait_until_triggered_fault
-------------------------------
Success:
(1 row)
-- We should have skipped recycling the awaiting drop segment because the segment was still visible to the SELECT gp_wait_until_triggered_fault query.
-1U: select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from pg_stat_progress_vacuum;
+select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id = 1;
relname | phase | heap_blks_total | heap_blks_scanned | heap_blks_vacuumed | index_vacuum_count | max_dead_tuples | num_dead_tuples
------------------------+-------------------------------+-----------------+-------------------+--------------------+--------------------+-----------------+-----------------
- vacuum_progress_ao_row | append-optimized post-cleanup | 165 | 55 | 110 | 0 | 100000 | 50000
+ vacuum_progress_ao_row | append-optimized post-cleanup | 55 | 19 | 37 | 0 | 33327 | 16622
(1 row)
-SELECT gp_inject_fault('vacuum_ao_post_cleanup_end', 'reset', dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum_summary;
+ relname | phase | heap_blks_total | heap_blks_scanned | heap_blks_vacuumed | index_vacuum_count | max_dead_tuples | num_dead_tuples
+------------------------+-------------------------------+-----------------+-------------------+--------------------+--------------------+-----------------+-----------------
+ vacuum_progress_ao_row | append-optimized post-cleanup | 166 | 57 | 111 | 0 | 100000 | 50000
+(1 row)
+
+SELECT gp_inject_fault('vacuum_ao_post_cleanup_end', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
gp_inject_fault
-----------------
Success:
-(1 row)
+ Success:
+ Success:
+(3 rows)
1<: <... completed>
VACUUM
@@ -166,63 +207,68 @@ VACUUM
SELECT relpages, reltuples, relallvisible FROM pg_class where relname = 'vacuum_progress_ao_row';
relpages | reltuples | relallvisible
----------+-----------+---------------
- 83 | 50000 | 0
+ 84 | 50000 | 0
(1 row)
SELECT n_live_tup, n_dead_tup, last_vacuum is not null as has_last_vacuum, vacuum_count FROM pg_stat_all_tables WHERE relname = 'vacuum_progress_ao_row';
n_live_tup | n_dead_tup | has_last_vacuum | vacuum_count
------------+------------+-----------------+--------------
- 50000 | 0 | t | 1
+ 16705 | 0 | t | 1
(1 row)
-- Perform VACUUM again to recycle the remaining awaiting drop segment marked by the previous run.
-SELECT gp_inject_fault('vacuum_ao_after_index_delete', 'suspend', dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+SELECT gp_inject_fault('vacuum_ao_after_index_delete', 'suspend', dbid) FROM gp_segment_configuration WHERE content = 0 AND role = 'p';
gp_inject_fault
-----------------
Success:
(1 row)
-1&: VACUUM vacuum_progress_ao_row; <waiting ...>
--- Resume execution and entering pre_cleanup phase, suspend at vacuuming indexes.
-SELECT gp_inject_fault('vacuum_ao_after_compact', 'reset', dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+SELECT gp_inject_fault('appendonly_after_truncate_segment_file', 'suspend', dbid) FROM gp_segment_configuration WHERE content > 0 AND role = 'p';
gp_inject_fault
-----------------
Success:
-(1 row)
-SELECT gp_wait_until_triggered_fault('vacuum_ao_after_index_delete', 1, dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+ Success:
+(2 rows)
+1&: VACUUM vacuum_progress_ao_row; <waiting ...>
+-- Resume execution and entering pre_cleanup phase, suspend at vacuuming indexes for segment 0.
+SELECT gp_wait_until_triggered_fault('vacuum_ao_after_index_delete', 1, dbid) FROM gp_segment_configuration WHERE content = 0 AND role = 'p';
gp_wait_until_triggered_fault
-------------------------------
Success:
(1 row)
--- We are in vacuuming indexes phase (part of ao pre_cleanup phase), index_vacuum_count should increase to 1.
-1U: select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from pg_stat_progress_vacuum;
+-- Resume execution and moving on to truncate segments that were marked as AWAITING_DROP for segment 1 and 2, there should be only 1.
+SELECT gp_wait_until_triggered_fault('appendonly_after_truncate_segment_file', 1, dbid) FROM gp_segment_configuration WHERE content > 0 AND role = 'p';
+ gp_wait_until_triggered_fault
+-------------------------------
+ Success:
+ Success:
+(2 rows)
+-- Segment 0 is in vacuuming indexes phase (part of ao pre_cleanup phase), index_vacuum_count should increase to 1.
+select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id = 0;
relname | phase | heap_blks_total | heap_blks_scanned | heap_blks_vacuumed | index_vacuum_count | max_dead_tuples | num_dead_tuples
------------------------+-------------------+-----------------+-------------------+--------------------+--------------------+-----------------+-----------------
- vacuum_progress_ao_row | vacuuming indexes | 83 | 0 | 0 | 1 | 50000 | 0
+ vacuum_progress_ao_row | vacuuming indexes | 28 | 0 | 0 | 1 | 16737 | 0
(1 row)
+-- Segment 1 and 2 are in truncate segments phase (part of ao post_cleanup phase), heap_blks_vacuumed should increase to 1.
+select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id > 0;
+ relname | phase | heap_blks_total | heap_blks_scanned | heap_blks_vacuumed | index_vacuum_count | max_dead_tuples | num_dead_tuples
+------------------------+------------------------------+-----------------+-------------------+--------------------+--------------------+-----------------+-----------------
+ vacuum_progress_ao_row | append-optimized pre-cleanup | 28 | 0 | 19 | 2 | 16558 | 0
+ vacuum_progress_ao_row | append-optimized pre-cleanup | 28 | 0 | 19 | 2 | 16705 | 0
+(2 rows)
+select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum_summary;
+ relname | phase | heap_blks_total | heap_blks_scanned | heap_blks_vacuumed | index_vacuum_count | max_dead_tuples | num_dead_tuples
+------------------------+------------------------------+-----------------+-------------------+--------------------+--------------------+-----------------+-----------------
+ vacuum_progress_ao_row | append-optimized pre-cleanup | 56 | 0 | 38 | 4 | 33263 | 0
+ vacuum_progress_ao_row | vacuuming indexes | 28 | 0 | 0 | 1 | 16737 | 0
+(2 rows)
--- Resume execution and moving on to truncate segments that were marked as AWAITING_DROP, there should be only 1.
-SELECT gp_inject_fault('appendonly_after_truncate_segment_file', 'suspend', dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+SELECT gp_inject_fault('appendonly_after_truncate_segment_file', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
gp_inject_fault
-----------------
Success:
-(1 row)
-SELECT gp_inject_fault('vacuum_ao_after_index_delete', 'reset', dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
- gp_inject_fault
------------------
Success:
-(1 row)
-SELECT gp_wait_until_triggered_fault('appendonly_after_truncate_segment_file', 1, dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
- gp_wait_until_triggered_fault
--------------------------------
- Success:
-(1 row)
--- We are in post_cleanup phase and should have truncated the old segfile. Both indexes should be vacuumed by now, and heap_blks_vacuumed should also increased
-1U: select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from pg_stat_progress_vacuum;
- relname | phase | heap_blks_total | heap_blks_scanned | heap_blks_vacuumed | index_vacuum_count | max_dead_tuples | num_dead_tuples
-------------------------+------------------------------+-----------------+-------------------+--------------------+--------------------+-----------------+-----------------
- vacuum_progress_ao_row | append-optimized pre-cleanup | 83 | 0 | 55 | 2 | 50000 | 0
-(1 row)
-
-SELECT gp_inject_fault('appendonly_after_truncate_segment_file', 'reset', dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+ Success:
+(3 rows)
+SELECT gp_inject_fault('vacuum_ao_after_index_delete', 'reset', dbid) FROM gp_segment_configuration WHERE content = 0 AND role = 'p';
gp_inject_fault
-----------------
Success:
@@ -230,25 +276,34 @@ SELECT gp_inject_fault('appendonly_after_truncate_segment_file', 'reset', dbid)
1<: <... completed>
VACUUM
--- Vacuum has finished, nothing should show up in the progress view.
-1U: select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from pg_stat_progress_vacuum;
+-- Vacuum has finished, nothing should show up in the view.
+select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id = 1;
+ relname | phase | heap_blks_total | heap_blks_scanned | heap_blks_vacuumed | index_vacuum_count | max_dead_tuples | num_dead_tuples
+---------+-------+-----------------+-------------------+--------------------+--------------------+-----------------+-----------------
+(0 rows)
+select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum_summary;
relname | phase | heap_blks_total | heap_blks_scanned | heap_blks_vacuumed | index_vacuum_count | max_dead_tuples | num_dead_tuples
---------+-------+-----------------+-------------------+--------------------+--------------------+-----------------+-----------------
(0 rows)
-- pg_class and collected stats view should be updated after the 2nd VACUUM
-1U: SELECT wait_until_dead_tup_change_to('vacuum_progress_ao_row'::regclass::oid, 0);
- wait_until_dead_tup_change_to
--------------------------------
- OK
+1U: SELECT wait_until_vacuum_count_change_to('vacuum_progress_ao_row'::regclass::oid, 2);
+ wait_until_vacuum_count_change_to
+-----------------------------------
+ OK
(1 row)
SELECT relpages, reltuples, relallvisible FROM pg_class where relname = 'vacuum_progress_ao_row';
relpages | reltuples | relallvisible
----------+-----------+---------------
- 28 | 50000 | 0
+ 30 | 50000 | 0
(1 row)
SELECT n_live_tup, n_dead_tup, last_vacuum is not null as has_last_vacuum, vacuum_count FROM pg_stat_all_tables WHERE relname = 'vacuum_progress_ao_row';
n_live_tup | n_dead_tup | has_last_vacuum | vacuum_count
+------------+------------+-----------------+--------------
+ 16705 | 0 | t | 2
+(1 row)
+SELECT n_live_tup, n_dead_tup, last_vacuum is not null as has_last_vacuum, vacuum_count FROM gp_stat_all_tables_summary WHERE relname = 'vacuum_progress_ao_row';
+ n_live_tup | n_dead_tup | has_last_vacuum | vacuum_count
------------+------------+-----------------+--------------
50000 | 0 | t | 2
(1 row)
diff --git a/src/test/isolation2/isolation2_schedule b/src/test/isolation2/isolation2_schedule
index aec0005e8d8..d9d33ad76e4 100644
--- a/src/test/isolation2/isolation2_schedule
+++ b/src/test/isolation2/isolation2_schedule
@@ -236,6 +236,7 @@ test: idle_gang_cleaner
# test idle_in_transaction_session_timeout
test: ao_index_build_progress
+test: analyze_progress
# Tests for FTS
test: fts_errors
diff --git a/src/test/isolation2/sql/analyze_progress.sql b/src/test/isolation2/sql/analyze_progress.sql
new file mode 100644
index 00000000000..311ab161eb2
--- /dev/null
+++ b/src/test/isolation2/sql/analyze_progress.sql
@@ -0,0 +1,42 @@
+-- Test gp_stat_progress_analyze_summary
+-- setup hash distributed table
+CREATE TABLE t_analyze_part (a INT, b INT) DISTRIBUTED BY (a);
+INSERT INTO t_analyze_part SELECT i, i FROM generate_series(1, 100000) i;
+
+-- Suspend analyze after scanning 20 blocks on each segment
+SELECT gp_inject_fault('analyze_block', 'suspend', '', '', '', 20, 20, 0, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+
+-- session 1: analyze the table
+1&: ANALYZE t_analyze_part;
+SELECT gp_wait_until_triggered_fault('analyze_block', 1, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+
+-- session 2: query pg_stat_progress_analyze while the analyze is running, the view should indicate 60 blocks have been scanned as aggregated progress of 3 segments
+2: SELECT pid IS NOT NULL as has_pid, datname, relid::regclass, phase, sample_blks_total, sample_blks_scanned FROM gp_stat_progress_analyze_summary;
+
+-- Reset fault injector
+SELECT gp_inject_fault('analyze_block', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+1<:
+
+-- teardown
+DROP TABLE t_analyze_part;
+
+-- setup replicated table
+CREATE TABLE t_analyze_repl (a INT, b INT) DISTRIBUTED REPLICATED;
+INSERT INTO t_analyze_repl SELECT i, i FROM generate_series(1, 100000) i;
+
+-- Suspend analyze after scanning 20 blocks on each segment
+SELECT gp_inject_fault('analyze_block', 'suspend', '', '', '', 20, 20, 0, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+
+-- session 1: analyze the table
+1&: ANALYZE t_analyze_repl;
+SELECT gp_wait_until_triggered_fault('analyze_block', 1, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+
+-- session 2: query pg_stat_progress_analyze while the analyze is running, the view should indicate 20 blocks have been scanned as average progress of 3 segments
+2: SELECT pid IS NOT NULL as has_pid, datname, relid::regclass, phase, sample_blks_total, sample_blks_scanned FROM gp_stat_progress_analyze_summary;
+
+-- Reset fault injector
+SELECT gp_inject_fault('analyze_block', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+1<:
+
+-- teardown
+DROP TABLE t_analyze_repl;
diff --git a/src/test/isolation2/sql/ao_index_build_progress.sql b/src/test/isolation2/sql/ao_index_build_progress.sql
index 19aade99e29..c5e34d1eab7 100644
--- a/src/test/isolation2/sql/ao_index_build_progress.sql
+++ b/src/test/isolation2/sql/ao_index_build_progress.sql
@@ -7,30 +7,34 @@ CREATE TABLE ao_index_build_progress(i int, j bigint) USING ao_row
-- Insert all tuples to seg1.
INSERT INTO ao_index_build_progress SELECT 0, i FROM generate_series(1, 100000) i;
+INSERT INTO ao_index_build_progress SELECT 2, i FROM generate_series(1, 100000) i;
+INSERT INTO ao_index_build_progress SELECT 5, i FROM generate_series(1, 100000) i;
-- Suspend execution when some blocks have been read.
SELECT gp_inject_fault('AppendOnlyStorageRead_ReadNextBlock_success', 'suspend', '', '', '', 10, 10, 0, dbid)
- FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+ FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
1&: CREATE INDEX ON ao_index_build_progress(i);
-- Wait until some AO varblocks have been read.
SELECT gp_wait_until_triggered_fault('AppendOnlyStorageRead_ReadNextBlock_success', 10, dbid)
- FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+ FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
-- By now, we should have reported some blocks (of size 'block_size') as "done",
-- as well as a total number of blocks that matches the relation's on-disk size.
-1U: SELECT command, phase,
+SELECT command, phase,
(pg_relation_size('ao_index_build_progress') +
(current_setting('block_size')::int - 1)) / current_setting('block_size')::int
AS blocks_total_actual,
blocks_total AS blocks_total_reported,
blocks_done AS blocks_done_reported
- FROM pg_stat_progress_create_index
- WHERE relid = 'ao_index_build_progress'::regclass;
+ FROM gp_stat_progress_create_index
+ WHERE gp_segment_id = 1 AND relid = 'ao_index_build_progress'::regclass;
+-- The same should be true for the summary view, and the total number of blocks should be tripled.
+SELECT command, phase, blocks_total, blocks_done FROM gp_stat_progress_create_index_summary WHERE relid = 'ao_index_build_progress'::regclass;
SELECT gp_inject_fault('AppendOnlyStorageRead_ReadNextBlock_success', 'reset', dbid)
- FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+ FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
1<:
@@ -40,31 +44,35 @@ CREATE TABLE aoco_index_build_progress(i int, j int ENCODING (compresstype=zstd,
-- Insert all tuples to seg1.
INSERT INTO aoco_index_build_progress SELECT 0, i FROM generate_series(1, 100000) i;
+INSERT INTO aoco_index_build_progress SELECT 2, i FROM generate_series(1, 100000) i;
+INSERT INTO aoco_index_build_progress SELECT 5, i FROM generate_series(1, 100000) i;
-- Suspend execution when some blocks have been read.
SELECT gp_inject_fault('AppendOnlyStorageRead_ReadNextBlock_success', 'suspend', '', '', '', 5, 5, 0, dbid)
- FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+ FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
1&: CREATE INDEX ON aoco_index_build_progress(i);
-- Wait until some AOCO varblocks have been read.
SELECT gp_wait_until_triggered_fault('AppendOnlyStorageRead_ReadNextBlock_success', 5, dbid)
- FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+ FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
-- By now, we should have reported some blocks (of size 'block_size') as "done",
-- as well as a total number of blocks that matches the relation's on-disk size.
-- Note: all blocks for the relation have to be scanned as we are building an
-- index for the first time and a block directory has to be created.
-1U: SELECT command, phase,
+SELECT command, phase,
(pg_relation_size('aoco_index_build_progress') +
(current_setting('block_size')::int - 1)) / current_setting('block_size')::int AS blocks_total_actual,
blocks_total AS blocks_total_reported,
blocks_done AS blocks_done_reported
- FROM pg_stat_progress_create_index
- WHERE relid = 'aoco_index_build_progress'::regclass;
+ FROM gp_stat_progress_create_index
+ WHERE gp_segment_id = 1 AND relid = 'aoco_index_build_progress'::regclass;
+-- The same should be true for the summary view, and the total number of blocks should be tripled.
+SELECT command, phase, blocks_total, blocks_done FROM gp_stat_progress_create_index_summary WHERE relid = 'aoco_index_build_progress'::regclass;
SELECT gp_inject_fault('AppendOnlyStorageRead_ReadNextBlock_success', 'reset', dbid)
- FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+ FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
1<:
@@ -72,13 +80,13 @@ SELECT gp_inject_fault('AppendOnlyStorageRead_ReadNextBlock_success', 'reset', d
-- Suspend execution when some blocks have been read.
SELECT gp_inject_fault('AppendOnlyStorageRead_ReadNextBlock_success', 'suspend', '', '', '', 5, 5, 0, dbid)
- FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+ FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
1&: CREATE INDEX ON aoco_index_build_progress(j);
-- Wait until some AOCO varblocks have been read.
SELECT gp_wait_until_triggered_fault('AppendOnlyStorageRead_ReadNextBlock_success', 5, dbid)
- FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+ FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
-- By now, we should have reported some blocks (of size 'block_size') as "done",
-- as well as a total number of blocks that matches the size of col j's segfile.
@@ -90,10 +98,12 @@ SELECT gp_wait_until_triggered_fault('AppendOnlyStorageRead_ReadNextBlock_succes
AS col_j_blocks,
blocks_total AS blocks_total_reported,
blocks_done AS blocks_done_reported
- FROM pg_stat_progress_create_index
- WHERE relid = 'aoco_index_build_progress'::regclass;
+ FROM gp_stat_progress_create_index
+ WHERE gp_segment_id = 1 AND relid = 'aoco_index_build_progress'::regclass;
+-- The same should be true for the summary view, and the total number of blocks should be tripled.
+SELECT command, phase, blocks_total, blocks_done FROM gp_stat_progress_create_index_summary WHERE relid = 'aoco_index_build_progress'::regclass;
SELECT gp_inject_fault('AppendOnlyStorageRead_ReadNextBlock_success', 'reset', dbid)
- FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+ FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
1<:
diff --git a/src/test/isolation2/sql/setup.sql b/src/test/isolation2/sql/setup.sql
index 949f22f0002..6241413ba3b 100644
--- a/src/test/isolation2/sql/setup.sql
+++ b/src/test/isolation2/sql/setup.sql
@@ -461,6 +461,27 @@ begin
end; /* in func */
$$ language plpgsql;
+-- Helper function that ensures stats collector receives stat from the latest operation.
+create or replace function wait_until_vacuum_count_change_to(relid oid, stat_val_expected bigint)
+ returns text as $$
+declare
+ stat_val int; /* in func */
+ i int; /* in func */
+begin
+ i := 0; /* in func */
+ while i < 1200 loop
+ select pg_stat_get_vacuum_count(relid) into stat_val; /* in func */
+ if stat_val = stat_val_expected then /* in func */
+ return 'OK'; /* in func */
+ end if; /* in func */
+ perform pg_sleep(0.1); /* in func */
+ perform pg_stat_clear_snapshot(); /* in func */
+ i := i + 1; /* in func */
+ end loop; /* in func */
+ return 'Fail'; /* in func */
+end; /* in func */
+$$ language plpgsql;
+
-- Helper function to get the number of blocks in a relation.
CREATE OR REPLACE FUNCTION nblocks(rel regclass) RETURNS int AS $$ /* in func */
BEGIN /* in func */
diff --git a/src/test/isolation2/sql/vacuum_progress_row.sql b/src/test/isolation2/sql/vacuum_progress_row.sql
index 1ccf6ca090f..93da2a47bbc 100644
--- a/src/test/isolation2/sql/vacuum_progress_row.sql
+++ b/src/test/isolation2/sql/vacuum_progress_row.sql
@@ -11,16 +11,15 @@ CREATE TABLE vacuum_progress_ao_row(i int, j int);
CREATE INDEX on vacuum_progress_ao_row(i);
CREATE INDEX on vacuum_progress_ao_row(j);
--- Insert all tuples to seg1 from two current sessions so that data are stored
--- in two segment files.
+-- Insert from two current sessions so that data are stored in two segment files.
1: BEGIN;
2: BEGIN;
-1: INSERT INTO vacuum_progress_ao_row SELECT 0, i FROM generate_series(1, 100000) i;
-2: INSERT INTO vacuum_progress_ao_row SELECT 0, i FROM generate_series(1, 100000) i;
+1: INSERT INTO vacuum_progress_ao_row SELECT i, i FROM generate_series(1, 100000) i;
+2: INSERT INTO vacuum_progress_ao_row SELECT i, i FROM generate_series(1, 100000) i;
-- Commit so that the logical EOF of segno 2 is non-zero.
2: COMMIT;
2: BEGIN;
-2: INSERT INTO vacuum_progress_ao_row SELECT 0, i FROM generate_series(1, 100000) i;
+2: INSERT INTO vacuum_progress_ao_row SELECT i, i FROM generate_series(1, 100000) i;
-- Abort so that segno 2 has dead tuples after its logical EOF
2: ABORT;
2q:
@@ -32,40 +31,46 @@ DELETE FROM vacuum_progress_ao_row where j % 2 = 0;
-- Lookup pg_class and collected stats view before VACUUM
SELECT relpages, reltuples, relallvisible FROM pg_class where relname = 'vacuum_progress_ao_row';
-SELECT n_live_tup, n_dead_tup, last_vacuum, vacuum_count FROM pg_stat_all_tables WHERE relname = 'vacuum_progress_ao_row';
+SELECT n_live_tup, n_dead_tup, last_vacuum, vacuum_count FROM gp_stat_all_tables WHERE relname = 'vacuum_progress_ao_row' and gp_segment_id = 1;
+SELECT n_live_tup, n_dead_tup, last_vacuum, vacuum_count FROM gp_stat_all_tables_summary WHERE relname = 'vacuum_progress_ao_row';
-- Perform VACUUM and observe the progress
-- Suspend execution at pre-cleanup phase after truncating both segfiles to their logical EOF.
-SELECT gp_inject_fault('appendonly_after_truncate_segment_file', 'suspend', '', '', '', 2, 2, 0, dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+SELECT gp_inject_fault('appendonly_after_truncate_segment_file', 'suspend', '', '', '', 2, 2, 0, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
1: set Debug_appendonly_print_compaction to on;
1&: VACUUM vacuum_progress_ao_row;
SELECT gp_wait_until_triggered_fault('appendonly_after_truncate_segment_file', 2, dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
-- We are in pre_cleanup phase and some blocks should've been vacuumed by now
-1U: select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from pg_stat_progress_vacuum;
+select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id = 1;
+select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum_summary;
-- Resume execution and suspend again in the middle of compact phase
-SELECT gp_inject_fault('appendonly_insert', 'suspend', '', '', '', 200, 200, 0, dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
-SELECT gp_inject_fault('appendonly_after_truncate_segment_file', 'reset', dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+SELECT gp_inject_fault('appendonly_insert', 'suspend', '', '', '', 200, 200, 0, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+SELECT gp_inject_fault('appendonly_after_truncate_segment_file', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
SELECT gp_wait_until_triggered_fault('appendonly_insert', 200, dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
-- We are in compact phase. num_dead_tuples should increase as we move and count tuples, one by one.
-1U: select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from pg_stat_progress_vacuum;
+select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id = 1;
+select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum_summary;
-- Resume execution and suspend again after compacting all segfiles
-SELECT gp_inject_fault('vacuum_ao_after_compact', 'suspend', dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
-SELECT gp_inject_fault('appendonly_insert', 'reset', dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+SELECT gp_inject_fault('vacuum_ao_after_compact', 'suspend', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+SELECT gp_inject_fault('appendonly_insert', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
SELECT gp_wait_until_triggered_fault('vacuum_ao_after_compact', 1, dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
-- After compacting all segfiles we expect 50000 dead tuples
-1U: select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from pg_stat_progress_vacuum;
+select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id = 1;
+select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum_summary;
-- Resume execution and entering post_cleaup phase, suspend at the end of it.
-SELECT gp_inject_fault('vacuum_ao_post_cleanup_end', 'suspend', dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
-SELECT gp_inject_fault('vacuum_ao_after_compact', 'reset', dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+SELECT gp_inject_fault('vacuum_ao_post_cleanup_end', 'suspend', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+SELECT gp_inject_fault('vacuum_ao_after_compact', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
SELECT gp_wait_until_triggered_fault('vacuum_ao_post_cleanup_end', 1, dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
-- We should have skipped recycling the awaiting drop segment because the segment was still visible to the SELECT gp_wait_until_triggered_fault query.
-1U: select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from pg_stat_progress_vacuum;
-SELECT gp_inject_fault('vacuum_ao_post_cleanup_end', 'reset', dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id = 1;
+select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum_summary;
+
+SELECT gp_inject_fault('vacuum_ao_post_cleanup_end', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
1<:
-- pg_class and collected stats view should be updated after the 1st VACUUM
@@ -74,113 +79,34 @@ SELECT relpages, reltuples, relallvisible FROM pg_class where relname = 'vacuum_
SELECT n_live_tup, n_dead_tup, last_vacuum is not null as has_last_vacuum, vacuum_count FROM pg_stat_all_tables WHERE relname = 'vacuum_progress_ao_row';
-- Perform VACUUM again to recycle the remaining awaiting drop segment marked by the previous run.
-SELECT gp_inject_fault('vacuum_ao_after_index_delete', 'suspend', dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+SELECT gp_inject_fault('vacuum_ao_after_index_delete', 'suspend', dbid) FROM gp_segment_configuration WHERE content = 0 AND role = 'p';
+SELECT gp_inject_fault('appendonly_after_truncate_segment_file', 'suspend', dbid) FROM gp_segment_configuration WHERE content > 0 AND role = 'p';
1&: VACUUM vacuum_progress_ao_row;
--- Resume execution and entering pre_cleanup phase, suspend at vacuuming indexes.
-SELECT gp_inject_fault('vacuum_ao_after_compact', 'reset', dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
-SELECT gp_wait_until_triggered_fault('vacuum_ao_after_index_delete', 1, dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
--- We are in vacuuming indexes phase (part of ao pre_cleanup phase), index_vacuum_count should increase to 1.
-1U: select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from pg_stat_progress_vacuum;
-
--- Resume execution and moving on to truncate segments that were marked as AWAITING_DROP, there should be only 1.
-SELECT gp_inject_fault('appendonly_after_truncate_segment_file', 'suspend', dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
-SELECT gp_inject_fault('vacuum_ao_after_index_delete', 'reset', dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
-SELECT gp_wait_until_triggered_fault('appendonly_after_truncate_segment_file', 1, dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
--- We are in post_cleanup phase and should have truncated the old segfile. Both indexes should be vacuumed by now, and heap_blks_vacuumed should also increased
-1U: select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from pg_stat_progress_vacuum;
-
-SELECT gp_inject_fault('appendonly_after_truncate_segment_file', 'reset', dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+-- Resume execution and entering pre_cleanup phase, suspend at vacuuming indexes for segment 0.
+SELECT gp_wait_until_triggered_fault('vacuum_ao_after_index_delete', 1, dbid) FROM gp_segment_configuration WHERE content = 0 AND role = 'p';
+-- Resume execution and moving on to truncate segments that were marked as AWAITING_DROP for segment 1 and 2, there should be only 1.
+SELECT gp_wait_until_triggered_fault('appendonly_after_truncate_segment_file', 1, dbid) FROM gp_segment_configuration WHERE content > 0 AND role = 'p';
+-- Segment 0 is in vacuuming indexes phase (part of ao pre_cleanup phase), index_vacuum_count should increase to 1.
+select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id = 0;
+-- Segment 1 and 2 are in truncate segments phase (part of ao post_cleanup phase), heap_blks_vacuumed should increase to 1.
+select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id > 0;
+select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum_summary;
+
+SELECT gp_inject_fault('appendonly_after_truncate_segment_file', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+SELECT gp_inject_fault('vacuum_ao_after_index_delete', 'reset', dbid) FROM gp_segment_configuration WHERE content = 0 AND role = 'p';
1<:
--- Vacuum has finished, nothing should show up in the progress view.
-1U: select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from pg_stat_progress_vacuum;
+-- Vacuum has finished, nothing should show up in the view.
+select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id = 1;
+select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum_summary;
-- pg_class and collected stats view should be updated after the 2nd VACUUM
-1U: SELECT wait_until_dead_tup_change_to('vacuum_progress_ao_row'::regclass::oid, 0);
+1U: SELECT wait_until_vacuum_count_change_to('vacuum_progress_ao_row'::regclass::oid, 2);
SELECT relpages, reltuples, relallvisible FROM pg_class where relname = 'vacuum_progress_ao_row';
-SELECT n_live_tup, n_dead_tup, last_vacuum is not null as has_last_vacuum, vacuum_count FROM pg_stat_all_tables WHERE relname = 'vacuum_progress_ao_row';
+SELECT n_live_tup, n_dead_tup, last_vacuum is not null as has_last_vacuum, vacuum_count FROM gp_stat_all_tables WHERE relname = 'vacuum_progress_ao_row' and gp_segment_id = 1;
+SELECT n_live_tup, n_dead_tup, last_vacuum is not null as has_last_vacuum, vacuum_count FROM gp_stat_all_tables_summary WHERE relname = 'vacuum_progress_ao_row';
--- open if system views gp_stat_progress_vacuum* are enabled
---1q:
----- Test vacuum worker process is changed at post-cleanup phase due to mirror down.
----- Current behavior is it will clear previous compact phase num_dead_tuples in post-cleanup
----- phase (at injecting point vacuum_ao_post_cleanup_end), which is different from above case
----- in which vacuum worker isn't changed.
---ALTER SYSTEM SET gp_fts_mark_mirror_down_grace_period to 10;
---ALTER SYSTEM SET gp_fts_probe_interval to 10;
---SELECT gp_segment_id, pg_reload_conf() FROM gp_id UNION SELECT gp_segment_id, pg_reload_conf() FROM gp_dist_random('gp_id');
---
---DROP TABLE IF EXISTS vacuum_progress_ao_row;
---CREATE TABLE vacuum_progress_ao_row(i int, j int);
---CREATE INDEX on vacuum_progress_ao_row(i);
---CREATE INDEX on vacuum_progress_ao_row(j);
---1: BEGIN;
---2: BEGIN;
---1: INSERT INTO vacuum_progress_ao_row SELECT i, i FROM generate_series(1, 100000) i;
---2: INSERT INTO vacuum_progress_ao_row SELECT i, i FROM generate_series(1, 100000) i;
---2: COMMIT;
---2: BEGIN;
---2: INSERT INTO vacuum_progress_ao_row SELECT i, i FROM generate_series(1, 100000) i;
---2: ABORT;
---2q:
---1: ABORT;
---DELETE FROM vacuum_progress_ao_row where j % 2 = 0;
---
----- Suspend execution at the end of compact phase.
---2: SELECT gp_inject_fault('vacuum_ao_after_compact', 'suspend', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
---
---1: set debug_appendonly_print_compaction to on;
---1&: vacuum vacuum_progress_ao_row;
---
---2: SELECT gp_wait_until_triggered_fault('vacuum_ao_after_compact', 3, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
---
----- Non-zero progressing data num_dead_tuples is showed up.
---select gp_segment_id, relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id > -1;
---select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum_summary;
---
----- Resume execution of compact phase and block at syncrep.
---2: SELECT gp_inject_fault_infinite('wal_sender_loop', 'suspend', dbid) FROM gp_segment_configuration WHERE role = 'p' and content = 1;
---2: SELECT gp_inject_fault('vacuum_ao_after_compact', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
----- stop the mirror should turn off syncrep
---2: SELECT pg_ctl(datadir, 'stop', 'immediate') FROM gp_segment_configuration WHERE content=1 AND role = 'm';
---
----- Resume walsender to detect mirror down and suspend at the beginning
----- of post-cleanup taken over by a new vacuum worker.
---2: SELECT gp_inject_fault('vacuum_worker_changed', 'suspend', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
----- resume walsender and let it exit so that mirror stop can be detected
---2: SELECT gp_inject_fault_infinite('wal_sender_loop', 'reset', dbid) FROM gp_segment_configuration WHERE role = 'p' and content = 1;
----- Ensure we enter into the target logic which stops cumulative data but
----- initializes a new vacrelstats at the beginning of post-cleanup phase.
----- Also all segments should reach to the same "vacuum_worker_changed" point
----- due to FTS version being changed.
---2: SELECT gp_wait_until_triggered_fault('vacuum_worker_changed', 1, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
----- now seg1's mirror is marked as down
---2: SELECT content, role, preferred_role, mode, status FROM gp_segment_configuration WHERE content > -1;
---
----- Resume execution and entering post_cleaup phase, suspend at the end of it.
---2: SELECT gp_inject_fault('vacuum_ao_post_cleanup_end', 'suspend', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
---2: SELECT gp_inject_fault('vacuum_worker_changed', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
---2: SELECT gp_wait_until_triggered_fault('vacuum_ao_post_cleanup_end', 1, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
---
----- The previous collected num_dead_tuples in compact phase is zero.
---select gp_segment_id, relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id > -1;
---select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum_summary;
---
---2: SELECT gp_inject_fault('vacuum_ao_post_cleanup_end', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
---
---1<:
---
----- restore environment
---1: reset debug_appendonly_print_compaction;
---
---2: SELECT pg_ctl_start(datadir, port) FROM gp_segment_configuration WHERE role = 'm' AND content = 1;
---2: SELECT wait_until_all_segments_synchronized();
---
----- Cleanup
---SELECT gp_inject_fault_infinite('all', 'reset', dbid) FROM gp_segment_configuration;
---reset Debug_appendonly_print_compaction;
---reset default_table_access_method;
---ALTER SYSTEM RESET gp_fts_mark_mirror_down_grace_period;
---ALTER SYSTEM RESET gp_fts_probe_interval;
---SELECT gp_segment_id, pg_reload_conf() FROM gp_id UNION SELECT gp_segment_id, pg_reload_conf() FROM gp_dist_random('gp_id');
---
\ No newline at end of file
+-- Cleanup
+SELECT gp_inject_fault_infinite('all', 'reset', dbid) FROM gp_segment_configuration;
+reset Debug_appendonly_print_compaction;
+reset default_table_access_method;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org
(cloudberry) 03/04: Add gp summary system views
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
maxyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git
commit 2b1c9c306eab532635fb598a3de8d330040a6fea
Author: Andrew Repp <re...@vmware.com>
AuthorDate: Fri Apr 7 16:34:44 2023 -0500
Add gp summary system views
These summary views offer basic aggregation of the gp_stat_* views across Greenplum coordinator and
segments.
Aggregation logic applied as follows:
* Time related (last_%): use max()
* Transaction related, not innately summable (number of commits/rollbacks) : use max()
* Table specific: sum()/numsegments for replicated tables, sum() for
distributed tables
* Innately summable stats, if no particular table is involved: use sum()
* pid: use coordinator's pid (not used here, but this is the convention in other gp_%_summary views)
---
src/backend/catalog/system_views.sql | 122 --------
src/backend/catalog/system_views_gp_summary.sql | 381 ++++++++++++++++++++++++
2 files changed, 381 insertions(+), 122 deletions(-)
diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql
index 4b8c9c0df43..d4d00b67771 100644
--- a/src/backend/catalog/system_views.sql
+++ b/src/backend/catalog/system_views.sql
@@ -692,81 +692,6 @@ CREATE VIEW pg_stat_all_tables AS
WHERE C.relkind IN ('r', 't', 'm', 'o', 'b', 'M', 'p')
GROUP BY C.oid, N.nspname, C.relname;
--- Gather data from segments on user tables, and use data on coordinator on system tables.
-
-CREATE VIEW gp_stat_all_tables_summary AS
-SELECT
- s.relid,
- s.schemaname,
- s.relname,
- m.seq_scan,
- m.seq_tup_read,
- m.idx_scan,
- m.idx_tup_fetch,
- m.n_tup_ins,
- m.n_tup_upd,
- m.n_tup_del,
- m.n_tup_hot_upd,
- m.n_live_tup,
- m.n_dead_tup,
- m.n_mod_since_analyze,
- m.n_ins_since_vacuum,
- s.last_vacuum,
- s.last_autovacuum,
- s.last_analyze,
- s.last_autoanalyze,
- s.vacuum_count,
- s.autovacuum_count,
- s.analyze_count,
- s.autoanalyze_count
-FROM
- (SELECT
- allt.relid,
- allt.schemaname,
- allt.relname,
- case when d.policytype = 'r' then (sum(seq_scan)/d.numsegments)::bigint else sum(seq_scan) end seq_scan,
- case when d.policytype = 'r' then (sum(seq_tup_read)/d.numsegments)::bigint else sum(seq_tup_read) end seq_tup_read,
- case when d.policytype = 'r' then (sum(idx_scan)/d.numsegments)::bigint else sum(idx_scan) end idx_scan,
- case when d.policytype = 'r' then (sum(idx_tup_fetch)/d.numsegments)::bigint else sum(idx_tup_fetch) end idx_tup_fetch,
- case when d.policytype = 'r' then (sum(n_tup_ins)/d.numsegments)::bigint else sum(n_tup_ins) end n_tup_ins,
- case when d.policytype = 'r' then (sum(n_tup_upd)/d.numsegments)::bigint else sum(n_tup_upd) end n_tup_upd,
- case when d.policytype = 'r' then (sum(n_tup_del)/d.numsegments)::bigint else sum(n_tup_del) end n_tup_del,
- case when d.policytype = 'r' then (sum(n_tup_hot_upd)/d.numsegments)::bigint else sum(n_tup_hot_upd) end n_tup_hot_upd,
- case when d.policytype = 'r' then (sum(n_live_tup)/d.numsegments)::bigint else sum(n_live_tup) end n_live_tup,
- case when d.policytype = 'r' then (sum(n_dead_tup)/d.numsegments)::bigint else sum(n_dead_tup) end n_dead_tup,
- case when d.policytype = 'r' then (sum(n_mod_since_analyze)/d.numsegments)::bigint else sum(n_mod_since_analyze) end n_mod_since_analyze,
- case when d.policytype = 'r' then (sum(n_ins_since_vacuum)/d.numsegments)::bigint else sum(n_ins_since_vacuum) end n_ins_since_vacuum,
- max(last_vacuum) as last_vacuum,
- max(last_autovacuum) as last_autovacuum,
- max(last_analyze) as last_analyze,
- max(last_autoanalyze) as last_autoanalyze,
- max(vacuum_count) as vacuum_count,
- max(autovacuum_count) as autovacuum_count,
- max(analyze_count) as analyze_count,
- max(autoanalyze_count) as autoanalyze_count
- FROM
- gp_dist_random('pg_stat_all_tables') allt
- inner join pg_class c
- on allt.relid = c.oid
- left outer join gp_distribution_policy d
- on allt.relid = d.localoid
- WHERE
- relid >= 16384
- and (
- d.localoid is not null
- or c.relkind in ('o', 'b', 'M')
- )
- GROUP BY allt.relid, allt.schemaname, allt.relname, d.policytype, d.numsegments
-
- UNION ALL
-
- SELECT
- *
- FROM
- pg_stat_all_tables
- WHERE
- relid < 16384) m, pg_stat_all_tables s
-WHERE m.relid = s.relid;
CREATE VIEW pg_stat_xact_all_tables AS
SELECT
@@ -819,10 +744,6 @@ CREATE VIEW pg_stat_user_tables_single_node AS
WHERE schemaname NOT IN ('pg_catalog', 'information_schema') AND
schemaname !~ '^pg_toast';
-CREATE VIEW gp_stat_user_tables_summary AS
- SELECT * FROM gp_stat_all_tables_summary
- WHERE schemaname NOT IN ('pg_catalog', 'information_schema') AND
- schemaname !~ '^pg_toast';
CREATE VIEW pg_stat_xact_user_tables AS
SELECT * FROM pg_stat_xact_all_tables
@@ -880,44 +801,6 @@ CREATE VIEW pg_stat_all_indexes AS
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE C.relkind IN ('r', 't', 'm', 'o', 'b', 'M');
--- Gather data from segments on user tables, and use data on coordinator on system tables.
-
-CREATE VIEW gp_stat_all_indexes_summary AS
-SELECT
- s.relid,
- s.indexrelid,
- s.schemaname,
- s.relname,
- s.indexrelname,
- m.idx_scan,
- m.idx_tup_read,
- m.idx_tup_fetch
-FROM
- (SELECT
- relid,
- indexrelid,
- schemaname,
- relname,
- indexrelname,
- sum(idx_scan) as idx_scan,
- sum(idx_tup_read) as idx_tup_read,
- sum(idx_tup_fetch) as idx_tup_fetch
- FROM
- gp_dist_random('pg_stat_all_indexes')
- WHERE
- relid >= 16384
- GROUP BY relid, indexrelid, schemaname, relname, indexrelname
-
- UNION ALL
-
- SELECT
- *
- FROM
- pg_stat_all_indexes
- WHERE
- relid < 16384) m, pg_stat_all_indexes s
-WHERE m.relid = s.relid;
-
CREATE VIEW pg_stat_sys_indexes AS
SELECT * FROM pg_stat_all_indexes
WHERE schemaname IN ('pg_catalog', 'information_schema', 'pg_aoseg') OR
@@ -928,11 +811,6 @@ CREATE VIEW pg_stat_user_indexes AS
WHERE schemaname NOT IN ('pg_catalog', 'information_schema') AND
schemaname !~ '^pg_toast';
-CREATE VIEW gp_stat_user_indexes_summary AS
- SELECT * FROM gp_stat_all_indexes_summary
- WHERE schemaname NOT IN ('pg_catalog', 'information_schema') AND
- schemaname !~ '^pg_toast';
-
CREATE VIEW pg_statio_all_indexes AS
SELECT
C.oid AS relid,
diff --git a/src/backend/catalog/system_views_gp_summary.sql b/src/backend/catalog/system_views_gp_summary.sql
index 58f4768c124..f83329203ab 100644
--- a/src/backend/catalog/system_views_gp_summary.sql
+++ b/src/backend/catalog/system_views_gp_summary.sql
@@ -22,6 +22,387 @@
* string literal (including a function body!) or a multiline comment.
*/
+CREATE VIEW gp_stat_archiver_summary AS
+SELECT
+ sum(gsa.archived_count) as archived_count,
+ max(gsa.last_archived_wal) as last_archived_wal,
+ max(gsa.last_archived_time) as last_archived_time,
+ sum(gsa.failed_count) as failed_count,
+ max(gsa.last_failed_wal) as last_failed_wal,
+ max(gsa.last_failed_time) as last_failed_time,
+ max(gsa.stats_reset) as stats_reset
+FROM
+ gp_stat_archiver gsa;
+
+CREATE VIEW gp_stat_bgwriter_summary AS
+SELECT
+ sum(gsb.checkpoints_timed) as checkpoints_timed,
+ sum(gsb.checkpoints_req) as checkpoints_req,
+ sum(gsb.checkpoint_write_time) as checkpoint_write_time,
+ sum(gsb.checkpoint_sync_time) as checkpoint_sync_time,
+ sum(gsb.buffers_checkpoint) as buffers_checkpoint,
+ sum(gsb.buffers_clean) as buffers_clean,
+ sum(gsb.maxwritten_clean) as maxwritten_clean,
+ sum(gsb.buffers_backend) as buffers_backend,
+ sum(gsb.buffers_backend_fsync) as buffers_backend_fsync,
+ sum(gsb.buffers_alloc) as buffers_alloc,
+ max(gsb.stats_reset) as stats_reset
+FROM
+ gp_stat_bgwriter gsb;
+
+CREATE VIEW gp_stat_wal_summary AS
+SELECT
+ sum(gsw.wal_records) as wal_records,
+ sum(gsw.wal_fpw) as wal_fpw,
+ sum(gsw.wal_bytes) as wal_bytes,
+ sum(gsw.wal_buffers_full) as wal_buffers_full,
+ sum(gsw.wal_write) as wal_write,
+ sum(gsw.wal_sync) as wal_sync,
+ sum(gsw.wal_write_time) as wal_write_time,
+ sum(gsw.wal_sync_time) as wal_sync_time,
+ max(gsw.stats_reset) as stats_reset
+from
+ gp_stat_wal gsw;
+
+CREATE VIEW gp_stat_database_summary AS
+SELECT
+ sdb.datid,
+ sdb.datname,
+ sum(sdb.numbackends) as numbackends,
+ max(sdb.xact_commit) as xact_commit,
+ max(sdb.xact_rollback) as xact_rollback,
+ sum(sdb.blks_read) as blks_read,
+ sum(sdb.blks_hit) as blks_hit,
+ sum(sdb.tup_returned) as tup_returned,
+ sum(sdb.tup_fetched) as tup_fetched,
+ sum(sdb.tup_inserted) as tup_inserted,
+ sum(sdb.tup_updated) as tup_updated,
+ sum(sdb.tup_deleted) as tup_deleted,
+ max(sdb.conflicts) as conflicts,
+ sum(sdb.temp_files) as temp_files,
+ sum(sdb.temp_bytes) as temp_bytes,
+ sum(sdb.deadlocks) as deadlocks,
+ sum(sdb.checksum_failures) as checksum_failures,
+ max(sdb.checksum_last_failure) as checksum_last_failure,
+ sum(sdb.blk_read_time) as blk_read_time,
+ sum(sdb.blk_write_time) as blk_write_time,
+ max(sdb.stats_reset) as stats_reset
+FROM
+ gp_stat_database sdb
+GROUP BY
+ sdb.datid,
+ sdb.datname;
+
+
+-- Gather data from segments on user tables, and use data on coordinator on system tables.
+CREATE VIEW gp_stat_all_tables_summary AS
+SELECT
+ s.relid,
+ s.schemaname,
+ s.relname,
+ m.seq_scan,
+ m.seq_tup_read,
+ m.idx_scan,
+ m.idx_tup_fetch,
+ m.n_tup_ins,
+ m.n_tup_upd,
+ m.n_tup_del,
+ m.n_tup_hot_upd,
+ m.n_live_tup,
+ m.n_dead_tup,
+ m.n_mod_since_analyze,
+ s.last_vacuum,
+ s.last_autovacuum,
+ s.last_analyze,
+ s.last_autoanalyze,
+ s.vacuum_count,
+ s.autovacuum_count,
+ s.analyze_count,
+ s.autoanalyze_count
+FROM
+ (SELECT
+ allt.relid,
+ allt.schemaname,
+ allt.relname,
+ case when d.policytype = 'r' then (sum(seq_scan)/d.numsegments)::bigint else sum(seq_scan) end seq_scan,
+ case when d.policytype = 'r' then (sum(seq_tup_read)/d.numsegments)::bigint else sum(seq_tup_read) end seq_tup_read,
+ case when d.policytype = 'r' then (sum(idx_scan)/d.numsegments)::bigint else sum(idx_scan) end idx_scan,
+ case when d.policytype = 'r' then (sum(idx_tup_fetch)/d.numsegments)::bigint else sum(idx_tup_fetch) end idx_tup_fetch,
+ case when d.policytype = 'r' then (sum(n_tup_ins)/d.numsegments)::bigint else sum(n_tup_ins) end n_tup_ins,
+ case when d.policytype = 'r' then (sum(n_tup_upd)/d.numsegments)::bigint else sum(n_tup_upd) end n_tup_upd,
+ case when d.policytype = 'r' then (sum(n_tup_del)/d.numsegments)::bigint else sum(n_tup_del) end n_tup_del,
+ case when d.policytype = 'r' then (sum(n_tup_hot_upd)/d.numsegments)::bigint else sum(n_tup_hot_upd) end n_tup_hot_upd,
+ case when d.policytype = 'r' then (sum(n_live_tup)/d.numsegments)::bigint else sum(n_live_tup) end n_live_tup,
+ case when d.policytype = 'r' then (sum(n_dead_tup)/d.numsegments)::bigint else sum(n_dead_tup) end n_dead_tup,
+ case when d.policytype = 'r' then (sum(n_mod_since_analyze)/d.numsegments)::bigint else sum(n_mod_since_analyze) end n_mod_since_analyze,
+ max(last_vacuum) as last_vacuum,
+ max(last_autovacuum) as last_autovacuum,
+ max(last_analyze) as last_analyze,
+ max(last_autoanalyze) as last_autoanalyze,
+ max(vacuum_count) as vacuum_count,
+ max(autovacuum_count) as autovacuum_count,
+ max(analyze_count) as analyze_count,
+ max(autoanalyze_count) as autoanalyze_count
+ FROM
+ gp_dist_random('pg_stat_all_tables') allt
+ inner join pg_class c
+ on allt.relid = c.oid
+ left outer join gp_distribution_policy d
+ on allt.relid = d.localoid
+ WHERE
+ relid >= 16384
+ and (
+ d.localoid is not null
+ or c.relkind in ('o', 'b', 'M')
+ )
+ GROUP BY allt.relid, allt.schemaname, allt.relname, d.policytype, d.numsegments
+
+ UNION ALL
+
+ SELECT
+ *
+ FROM
+ pg_stat_all_tables
+ WHERE
+ relid < 16384) m, pg_stat_all_tables s
+WHERE m.relid = s.relid;
+
+CREATE VIEW gp_stat_user_tables_summary AS
+ SELECT * FROM gp_stat_all_tables_summary
+ WHERE schemaname NOT IN ('pg_catalog', 'information_schema', 'pg_aoseg') AND
+ schemaname !~ '^pg_toast';
+
+CREATE VIEW gp_stat_sys_tables_summary AS
+ SELECT * FROM gp_stat_all_tables_summary
+ WHERE schemaname IN ('pg_catalog', 'information_schema', 'pg_aoseg') OR
+ schemaname ~ '^pg_toast';
+
+CREATE VIEW gp_stat_xact_all_tables_summary AS
+SELECT
+ sxa.relid,
+ sxa.schemaname,
+ sxa.relname,
+ CASE WHEN dst.policytype = 'r' THEN (sum(sxa.seq_scan)/dst.numsegments)::bigint ELSE sum(sxa.seq_scan) END AS seq_scan,
+ CASE WHEN dst.policytype = 'r' THEN (sum(sxa.seq_tup_read)/dst.numsegments)::bigint ELSE sum(sxa.seq_tup_read) END AS seq_tup_read,
+ CASE WHEN dst.policytype = 'r' THEN (sum(sxa.idx_scan)/dst.numsegments)::bigint ELSE sum(sxa.idx_scan) END AS idx_scan,
+ CASE WHEN dst.policytype = 'r' THEN (sum(sxa.idx_tup_fetch)/dst.numsegments)::bigint ELSE sum(sxa.idx_tup_fetch) END AS idx_tup_fetch,
+ CASE WHEN dst.policytype = 'r' THEN (sum(sxa.n_tup_ins)/dst.numsegments)::bigint ELSE sum(sxa.n_tup_ins) END AS n_tup_ins,
+ CASE WHEN dst.policytype = 'r' THEN (sum(sxa.n_tup_upd)/dst.numsegments)::bigint ELSE sum(sxa.n_tup_upd) END AS n_tup_upd,
+ CASE WHEN dst.policytype = 'r' THEN (sum(sxa.n_tup_del)/dst.numsegments)::bigint ELSE sum(sxa.n_tup_del) END AS n_tup_del,
+ CASE WHEN dst.policytype = 'r' THEN (sum(sxa.n_tup_hot_upd)/dst.numsegments)::bigint ELSE sum(sxa.n_tup_hot_upd) END AS n_tup_hot_upd
+FROM
+ gp_stat_xact_all_tables sxa
+ LEFT OUTER JOIN gp_distribution_policy dst
+ ON sxa.relid = dst.localoid
+GROUP BY
+ sxa.relid,
+ sxa.schemaname,
+ sxa.relname,
+ dst.policytype,
+ dst.numsegments;
+
+CREATE VIEW gp_stat_xact_sys_tables_summary as
+ SELECT * FROM gp_stat_xact_all_tables_summary
+ WHERE schemaname IN ('pg_catalog', 'information_schema', 'pg_aoseg') OR
+ schemaname ~ '^pg_toast';
+
+CREATE VIEW gp_stat_xact_user_tables_summary AS
+ SELECT * FROM gp_stat_xact_all_tables_summary
+ WHERE schemaname NOT IN ('pg_catalog', 'information_schema', 'pg_aoseg') AND
+ schemaname !~ '^pg_toast';
+
+-- Gather data from segments on user tables, and use data on coordinator on system tables.
+CREATE VIEW gp_stat_all_indexes_summary AS
+SELECT
+ s.relid,
+ s.indexrelid,
+ s.schemaname,
+ s.relname,
+ s.indexrelname,
+ m.idx_scan,
+ m.idx_tup_read,
+ m.idx_tup_fetch
+FROM
+ (SELECT
+ alli.relid,
+ alli.indexrelid,
+ alli.schemaname,
+ alli.relname,
+ alli.indexrelname,
+ case when d.policytype = 'r' then (sum(alli.idx_scan)/d.numsegments)::bigint else sum(alli.idx_scan) end idx_scan,
+ case when d.policytype = 'r' then (sum(alli.idx_tup_read)/d.numsegments)::bigint else sum(alli.idx_tup_read) end idx_tup_read,
+ case when d.policytype = 'r' then (sum(alli.idx_tup_fetch)/d.numsegments)::bigint else sum(alli.idx_tup_fetch) end idx_tup_fetch
+ FROM
+ gp_dist_random('pg_stat_all_indexes') alli
+ inner join pg_class c
+ on alli.relid = c.oid
+ left outer join gp_distribution_policy d
+ on alli.relid = d.localoid
+ WHERE
+ relid >= 16384
+ GROUP BY alli.relid, alli.indexrelid, alli.schemaname, alli.relname, alli.indexrelname, d.policytype, d.numsegments
+
+ UNION ALL
+
+ SELECT
+ *
+ FROM
+ pg_stat_all_indexes
+ WHERE
+ relid < 16384) m, pg_stat_all_indexes s
+WHERE m.relid = s.relid;
+
+CREATE VIEW gp_stat_sys_indexes_summary AS
+ SELECT * FROM gp_stat_all_indexes_summary
+ WHERE schemaname IN ('pg_catalog', 'information_schema', 'pg_aoseg') OR
+ schemaname ~ '^pg_toast';
+
+CREATE VIEW gp_stat_user_indexes_summary AS
+ SELECT * FROM gp_stat_all_indexes_summary
+ WHERE schemaname NOT IN ('pg_catalog', 'information_schema', 'pg_aoseg') AND
+ schemaname !~ '^pg_toast';
+
+CREATE VIEW gp_statio_all_tables_summary as
+SELECT
+ sat.relid,
+ sat.schemaname,
+ sat.relname,
+ CASE WHEN dst.policytype = 'r' THEN (sum(sat.heap_blks_read)/dst.numsegments)::bigint ELSE sum(sat.heap_blks_read) END AS heap_blks_read,
+ CASE WHEN dst.policytype = 'r' THEN (sum(sat.heap_blks_hit)/dst.numsegments)::bigint ELSE sum(sat.heap_blks_hit) END AS heap_blks_hit,
+ CASE WHEN dst.policytype = 'r' THEN (sum(sat.idx_blks_read)/dst.numsegments)::bigint ELSE sum(sat.idx_blks_read) END AS idx_blks_read,
+ CASE WHEN dst.policytype = 'r' THEN (sum(sat.idx_blks_hit)/dst.numsegments)::bigint ELSE sum(sat.idx_blks_hit) END AS idx_blks_hit,
+ CASE WHEN dst.policytype = 'r' THEN (sum(sat.toast_blks_read)/dst.numsegments)::bigint ELSE sum(sat.toast_blks_read) END AS toast_blks_read,
+ CASE WHEN dst.policytype = 'r' THEN (sum(sat.toast_blks_hit)/dst.numsegments)::bigint ELSE sum(sat.toast_blks_hit) END AS toast_blks_hit,
+ CASE WHEN dst.policytype = 'r' THEN (sum(sat.tidx_blks_read)/dst.numsegments)::bigint ELSE sum(sat.tidx_blks_read) END AS tidx_blks_read,
+ CASE WHEN dst.policytype = 'r' THEN (sum(sat.tidx_blks_hit)/dst.numsegments)::bigint ELSE sum(sat.tidx_blks_hit) END AS tidx_blks_hit
+FROM
+ gp_statio_all_tables sat
+ LEFT OUTER JOIN gp_distribution_policy dst
+ ON sat.relid = dst.localoid
+GROUP BY
+ sat.relid,
+ sat.schemaname,
+ sat.relname,
+ dst.policytype,
+ dst.numsegments;
+
+CREATE VIEW gp_statio_sys_tables_summary AS
+ SELECT * FROM gp_statio_all_tables_summary
+ WHERE schemaname IN ('pg_catalog', 'information_schema', 'pg_aoseg') OR
+ schemaname ~ '^pg_toast';
+
+CREATE VIEW gp_statio_user_tables_summary AS
+ SELECT * FROM gp_stat_all_tables_summary
+ WHERE schemaname NOT IN ('pg_catalog', 'information_schema', 'pg_aoseg') AND
+ schemaname !~ '^pg_toast';
+
+CREATE VIEW gp_statio_all_sequences_summary as
+SELECT
+ sas.relid,
+ sas.schemaname,
+ sas.relname,
+ CASE WHEN dst.policytype = 'r' THEN (sum(sas.blks_read)/dst.numsegments)::bigint ELSE sum(sas.blks_read) END AS blks_read,
+ CASE WHEN dst.policytype = 'r' THEN (sum(sas.blks_hit)/dst.numsegments)::bigint ELSE sum(sas.blks_hit) END AS blks_hit
+FROM
+ gp_statio_all_sequences sas
+ LEFT OUTER JOIN gp_distribution_policy dst
+ ON sas.relid = dst.localoid
+GROUP BY
+ sas.relid,
+ sas.schemaname,
+ sas.relname,
+ dst.policytype,
+ dst.numsegments;
+
+CREATE VIEW gp_statio_sys_sequences_summary AS
+ SELECT * FROM gp_statio_all_sequences_summary
+ WHERE schemaname IN ('pg_catalog', 'information_schema', 'pg_aoseg') OR
+ schemaname ~ '^pg_toast';
+
+CREATE VIEW gp_statio_user_sequences_summary AS
+ SELECT * FROM gp_statio_all_sequences_summary
+ WHERE schemaname NOT IN ('pg_catalog', 'information_schema', 'pg_aoseg') AND
+ schemaname !~ '^pg_toast';
+
+CREATE VIEW gp_statio_all_indexes_summary AS
+SELECT
+ sai.relid,
+ sai.indexrelid,
+ sai.schemaname,
+ sai.relname,
+ sai.indexrelname,
+ CASE WHEN dst.policytype = 'r' THEN (sum(sai.idx_blks_read)/dst.numsegments)::bigint ELSE sum(sai.idx_blks_read) END AS idx_blks_read,
+ CASE WHEN dst.policytype = 'r' THEN (sum(sai.idx_blks_hit)/dst.numsegments)::bigint ELSE sum(sai.idx_blks_hit) END AS idx_blks_hit
+FROM
+ gp_statio_all_indexes sai
+ LEFT OUTER JOIN gp_distribution_policy dst
+ ON sai.relid = dst.localoid
+GROUP BY
+ sai.relid,
+ sai.indexrelid,
+ sai.schemaname,
+ sai.relname,
+ sai.indexrelname,
+ dst.policytype,
+ dst.numsegments;
+
+CREATE VIEW gp_statio_sys_indexes_summary AS
+ SELECT * FROM gp_statio_all_indexes_summary
+ WHERE schemaname IN ('pg_catalog', 'information_schema', 'pg_aoseg') OR
+ schemaname ~ '^pg_toast';
+
+CREATE VIEW gp_statio_user_indexes_summary AS
+ SELECT * FROM gp_statio_all_indexes_summary
+ WHERE schemaname NOT IN ('pg_catalog', 'information_schema', 'pg_aoseg') AND
+ schemaname !~ '^pg_toast';
+
+CREATE VIEW gp_stat_user_functions_summary AS
+SELECT
+ guf.funcid,
+ guf.schemaname,
+ guf.funcname,
+ sum(guf.calls) AS calls,
+ sum(guf.total_time) AS total_time,
+ sum(guf.self_time) AS self_time
+FROM
+ gp_stat_user_functions guf
+GROUP BY
+ guf.funcid,
+ guf.schemaname,
+ guf.funcname;
+
+CREATE VIEW gp_stat_xact_user_functions_summary AS
+SELECT
+ xuf.funcid,
+ xuf.schemaname,
+ xuf.funcname,
+ sum(xuf.calls) AS calls,
+ sum(xuf.total_time) AS total_time,
+ sum(xuf.self_time) AS self_time
+FROM
+ gp_stat_xact_user_functions xuf
+GROUP BY
+ xuf.funcid,
+ xuf.schemaname,
+ xuf.funcname;
+
+CREATE VIEW gp_stat_slru_summary AS
+SELECT
+ gss.name,
+ sum(gss.blks_zeroed) AS blks_zeroed,
+ sum(gss.blks_hit) AS blks_hit,
+ sum(gss.blks_read) AS blks_read,
+ sum(gss.blks_written) AS blks_written,
+ sum(gss.blks_exists) AS blks_exists,
+ sum(gss.flushes) AS flushes,
+ sum(gss.truncates) AS truncates,
+ max(gss.stats_reset) AS stats_reset
+FROM
+ gp_stat_slru gss
+GROUP BY
+ gss.name;
+
+
CREATE VIEW gp_stat_progress_vacuum_summary AS
SELECT
max(coalesce(a1.pid, 0)) as pid,
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org
(cloudberry) 01/04: Fix names of pg_stat_all_tables|indexes
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
maxyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git
commit 5142c0e8afe0c8e6640c8157c067e1e25d20b0a5
Author: Huansong Fu <fu...@gmail.com>
AuthorDate: Mon Mar 20 14:29:50 2023 -0700
Fix names of pg_stat_all_tables|indexes
We used to not have a very clear naming guideline for the existing
'pg_%' system views and the MPP versions of them. As an example,
we renamed PG's pg_stat_all_tables and pg_stat_all_indexes to have
an '_internal' appendix, and used their original names to collect
aggregated results from all segments (commit e6f93033289e).
However, with the previous commit, we now let all existing PG system
views to have their original names, while add corresponding 'gp_%'
views for the non-aggregated results from all segments, and
'gp_%_summary' views for aggregated results from all segments.
Therefore, we now revert pg_stat_all_tables and pg_stat_all_indexes
back to their original definitions, which just collect stats from
a single segment. Then, we add them to sytem_views_gp.in to produce
gp_stat_all_tables and gp_stat_all_indexes which collect non-aggregated
results from all segments. Finally, we rename the aggregate version of
those views to be gp_stat_all_tables_summary and gp_stat_all_indexes_summary.
Because views pg_stat_user_tables and pg_stat_user_indexes use the above
sumary views, we have to add _summary views for these two views as well.
We will add _summary for other system views later.
Modify regress test accordingly.
---
src/backend/catalog/system_views.sql | 34 +++++++----
src/backend/catalog/system_views_gp.in | 2 +
src/test/regress/expected/pg_stat.out | 16 ++---
src/test/regress/input/pgstat_qd_tabstat.source | 76 ++++++++++++------------
src/test/regress/output/pgstat_qd_tabstat.source | 76 ++++++++++++------------
src/test/regress/sql/pg_stat.sql | 16 ++---
6 files changed, 116 insertions(+), 104 deletions(-)
diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql
index d5b7b81e8a2..4b8c9c0df43 100644
--- a/src/backend/catalog/system_views.sql
+++ b/src/backend/catalog/system_views.sql
@@ -660,7 +660,7 @@ REVOKE EXECUTE ON FUNCTION pg_get_backend_memory_contexts() FROM PUBLIC;
-- Statistics views
-CREATE VIEW pg_stat_all_tables_internal AS
+CREATE VIEW pg_stat_all_tables AS
SELECT
C.oid AS relid,
N.nspname AS schemaname,
@@ -694,7 +694,7 @@ CREATE VIEW pg_stat_all_tables_internal AS
-- Gather data from segments on user tables, and use data on coordinator on system tables.
-CREATE VIEW pg_stat_all_tables AS
+CREATE VIEW gp_stat_all_tables_summary AS
SELECT
s.relid,
s.schemaname,
@@ -745,7 +745,7 @@ FROM
max(analyze_count) as analyze_count,
max(autoanalyze_count) as autoanalyze_count
FROM
- gp_dist_random('pg_stat_all_tables_internal') allt
+ gp_dist_random('pg_stat_all_tables') allt
inner join pg_class c
on allt.relid = c.oid
left outer join gp_distribution_policy d
@@ -763,9 +763,9 @@ FROM
SELECT
*
FROM
- pg_stat_all_tables_internal
+ pg_stat_all_tables
WHERE
- relid < 16384) m, pg_stat_all_tables_internal s
+ relid < 16384) m, pg_stat_all_tables s
WHERE m.relid = s.relid;
CREATE VIEW pg_stat_xact_all_tables AS
@@ -815,7 +815,12 @@ CREATE VIEW pg_stat_user_tables AS
-- since we don't have segments.
-- We create a new view for single node mode.
CREATE VIEW pg_stat_user_tables_single_node AS
- SELECT * FROM pg_stat_all_tables_internal
+ SELECT * FROM pg_stat_all_tables
+ WHERE schemaname NOT IN ('pg_catalog', 'information_schema') AND
+ schemaname !~ '^pg_toast';
+
+CREATE VIEW gp_stat_user_tables_summary AS
+ SELECT * FROM gp_stat_all_tables_summary
WHERE schemaname NOT IN ('pg_catalog', 'information_schema') AND
schemaname !~ '^pg_toast';
@@ -859,7 +864,7 @@ CREATE VIEW pg_statio_user_tables AS
WHERE schemaname NOT IN ('pg_catalog', 'information_schema') AND
schemaname !~ '^pg_toast';
-CREATE VIEW pg_stat_all_indexes_internal AS
+CREATE VIEW pg_stat_all_indexes AS
SELECT
C.oid AS relid,
I.oid AS indexrelid,
@@ -877,7 +882,7 @@ CREATE VIEW pg_stat_all_indexes_internal AS
-- Gather data from segments on user tables, and use data on coordinator on system tables.
-CREATE VIEW pg_stat_all_indexes AS
+CREATE VIEW gp_stat_all_indexes_summary AS
SELECT
s.relid,
s.indexrelid,
@@ -898,7 +903,7 @@ FROM
sum(idx_tup_read) as idx_tup_read,
sum(idx_tup_fetch) as idx_tup_fetch
FROM
- gp_dist_random('pg_stat_all_indexes_internal')
+ gp_dist_random('pg_stat_all_indexes')
WHERE
relid >= 16384
GROUP BY relid, indexrelid, schemaname, relname, indexrelname
@@ -908,10 +913,10 @@ FROM
SELECT
*
FROM
- pg_stat_all_indexes_internal
+ pg_stat_all_indexes
WHERE
- relid < 16384) m, pg_stat_all_indexes_internal s
-WHERE m.indexrelid = s.indexrelid;
+ relid < 16384) m, pg_stat_all_indexes s
+WHERE m.relid = s.relid;
CREATE VIEW pg_stat_sys_indexes AS
SELECT * FROM pg_stat_all_indexes
@@ -923,6 +928,11 @@ CREATE VIEW pg_stat_user_indexes AS
WHERE schemaname NOT IN ('pg_catalog', 'information_schema') AND
schemaname !~ '^pg_toast';
+CREATE VIEW gp_stat_user_indexes_summary AS
+ SELECT * FROM gp_stat_all_indexes_summary
+ WHERE schemaname NOT IN ('pg_catalog', 'information_schema') AND
+ schemaname !~ '^pg_toast';
+
CREATE VIEW pg_statio_all_indexes AS
SELECT
C.oid AS relid,
diff --git a/src/backend/catalog/system_views_gp.in b/src/backend/catalog/system_views_gp.in
index d46dde3191e..cd865cea662 100644
--- a/src/backend/catalog/system_views_gp.in
+++ b/src/backend/catalog/system_views_gp.in
@@ -9,6 +9,8 @@ pg_replication_origin_status
pg_replication_slots
pg_settings
pg_stat_activity
+pg_stat_all_indexes
+pg_stat_all_tables
pg_stat_archiver
pg_stat_bgwriter
#pg_stat_database
diff --git a/src/test/regress/expected/pg_stat.out b/src/test/regress/expected/pg_stat.out
index 80e4e4ff132..8c2b2e81d32 100644
--- a/src/test/regress/expected/pg_stat.out
+++ b/src/test/regress/expected/pg_stat.out
@@ -5,7 +5,7 @@ create table pg_stat_test(a int);
select
schemaname, relname, seq_scan, seq_tup_read, idx_scan, idx_tup_fetch, n_tup_ins, n_tup_upd,
n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup
-from pg_stat_all_tables where relname = 'pg_stat_test';
+from gp_stat_all_tables_summary where relname = 'pg_stat_test';
schemaname | relname | seq_scan | seq_tup_read | idx_scan | idx_tup_fetch | n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup
------------+--------------+----------+--------------+----------+---------------+-----------+-----------+-----------+---------------+------------+------------
public | pg_stat_test | 0 | 0 | | | 0 | 0 | 0 | 0 | 0 | 0
@@ -14,7 +14,7 @@ from pg_stat_all_tables where relname = 'pg_stat_test';
select
schemaname, relname, seq_scan, seq_tup_read, idx_scan, idx_tup_fetch, n_tup_ins, n_tup_upd,
n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup
-from pg_stat_user_tables where relname = 'pg_stat_test';
+from gp_stat_user_tables_summary where relname = 'pg_stat_test';
schemaname | relname | seq_scan | seq_tup_read | idx_scan | idx_tup_fetch | n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup
------------+--------------+----------+--------------+----------+---------------+-----------+-----------+-----------+---------------+------------+------------
public | pg_stat_test | 0 | 0 | | | 0 | 0 | 0 | 0 | 0 | 0
@@ -22,14 +22,14 @@ from pg_stat_user_tables where relname = 'pg_stat_test';
select
schemaname, relname, indexrelname, idx_scan, idx_tup_read, idx_tup_fetch
-from pg_stat_all_indexes where relname = 'pg_stat_test';
+from gp_stat_all_indexes_summary where relname = 'pg_stat_test';
schemaname | relname | indexrelname | idx_scan | idx_tup_read | idx_tup_fetch
------------+---------+--------------+----------+--------------+---------------
(0 rows)
select
schemaname, relname, indexrelname, idx_scan, idx_tup_read, idx_tup_fetch
-from pg_stat_user_indexes where relname = 'pg_stat_test';
+from gp_stat_user_indexes_summary where relname = 'pg_stat_test';
schemaname | relname | indexrelname | idx_scan | idx_tup_read | idx_tup_fetch
------------+---------+--------------+----------+--------------+---------------
(0 rows)
@@ -63,7 +63,7 @@ reset enable_seqscan;
select
schemaname, relname, seq_scan, seq_tup_read, idx_scan, idx_tup_fetch, n_tup_ins, n_tup_upd,
n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze
-from pg_stat_all_tables where relname = 'pg_stat_test';
+from gp_stat_all_tables_summary where relname = 'pg_stat_test';
schemaname | relname | seq_scan | seq_tup_read | idx_scan | idx_tup_fetch | n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
------------+--------------+----------+--------------+----------+---------------+-----------+-----------+-----------+---------------+------------+------------+---------------------
public | pg_stat_test | 12 | 391 | 1 | 0 | 110 | 0 | 19 | 0 | 91 | 19 | 129
@@ -72,7 +72,7 @@ from pg_stat_all_tables where relname = 'pg_stat_test';
select
schemaname, relname, seq_scan, seq_tup_read, idx_scan, idx_tup_fetch, n_tup_ins, n_tup_upd,
n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze
-from pg_stat_user_tables where relname = 'pg_stat_test';
+from gp_stat_user_tables_summary where relname = 'pg_stat_test';
schemaname | relname | seq_scan | seq_tup_read | idx_scan | idx_tup_fetch | n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
------------+--------------+----------+--------------+----------+---------------+-----------+-----------+-----------+---------------+------------+------------+---------------------
public | pg_stat_test | 12 | 391 | 1 | 0 | 110 | 0 | 19 | 0 | 91 | 19 | 129
@@ -80,7 +80,7 @@ from pg_stat_user_tables where relname = 'pg_stat_test';
select
schemaname, relname, indexrelname, idx_scan, idx_tup_read, idx_tup_fetch
-from pg_stat_all_indexes where relname = 'pg_stat_test';
+from gp_stat_all_indexes_summary where relname = 'pg_stat_test';
schemaname | relname | indexrelname | idx_scan | idx_tup_read | idx_tup_fetch
------------+--------------+--------------------------+----------+--------------+---------------
public | pg_stat_test | pg_stat_user_table_index | 1 | 1 | 0
@@ -88,7 +88,7 @@ from pg_stat_all_indexes where relname = 'pg_stat_test';
select
schemaname, relname, indexrelname, idx_scan, idx_tup_read, idx_tup_fetch
-from pg_stat_user_indexes where relname = 'pg_stat_test';
+from gp_stat_user_indexes_summary where relname = 'pg_stat_test';
schemaname | relname | indexrelname | idx_scan | idx_tup_read | idx_tup_fetch
------------+--------------+--------------------------+----------+--------------+---------------
public | pg_stat_test | pg_stat_user_table_index | 1 | 1 | 0
diff --git a/src/test/regress/input/pgstat_qd_tabstat.source b/src/test/regress/input/pgstat_qd_tabstat.source
index 0fb8c0ccb71..e9f76ccf0d6 100644
--- a/src/test/regress/input/pgstat_qd_tabstat.source
+++ b/src/test/regress/input/pgstat_qd_tabstat.source
@@ -10,7 +10,7 @@ copy table_for_docopy (i, j) from stdin;
3 hello3
\.
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_docopy'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_docopy'::regclass;
CREATE TABLE data_tbl (a int,b char) distributed by (a);
INSERT INTO data_tbl values(1,'1');
@@ -21,7 +21,7 @@ COPY data_tbl TO '/tmp/data_tbl<SEGID>.csv' on segment;
create table copy_on_segment (a int,b char);
COPY copy_on_segment from '/tmp/data_tbl<SEGID>.csv' on segment log errors segment reject limit 3 rows;
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'copy_on_segment'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'copy_on_segment'::regclass;
-- Test pgstat table stat in initplan on QD
@@ -34,26 +34,26 @@ copy table_for_initplan (i, j, k) from stdin;
explain (costs off) with updated AS (update table_for_initplan set k = 33 where i = 3 returning k) select table_for_initplan.*, (select sum(k) from updated) from table_for_initplan;
with updated AS (update table_for_initplan set k = 33 where i = 3 returning k) select table_for_initplan.*, (select sum(k) from updated) from table_for_initplan;
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_initplan'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_initplan'::regclass;
-- Test pgstat table stat in CTAS on QD
create table table_for_ctas with (autovacuum_enabled=false) as select i, 'hello' || i from generate_series(1, 100) f(i);
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_ctas'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_ctas'::regclass;
select i, 'hello' || i into table_for_insert_into from generate_series(1, 100) f(i);
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_insert_into'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_insert_into'::regclass;
-- Test pgstat table stat in ALTER TABLE SET DISTRIBUTED BY on QD
create table table_for_set_distributed_by(i int, j varchar) distributed by (i);
insert into table_for_set_distributed_by select i, 'hello' || i from generate_series(1, 333) f(i);
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_set_distributed_by'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_set_distributed_by'::regclass;
alter table table_for_set_distributed_by set distributed by (j);
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_set_distributed_by'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_set_distributed_by'::regclass;
-- Test pgstat table stat in execution of funciton on QD
@@ -68,7 +68,7 @@ $$
language plpgsql volatile;
select update_table_for_function();
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_function'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_function'::regclass;
-- Test pgstat table stat in ALTER TABLE EXPAND TABLE on QD;
@@ -78,11 +78,11 @@ create table table_for_expand(i int, j varchar) distributed by (i);
insert into table_for_expand select i, 'hello' || i from generate_series(1, 333) f(i);
select count(distinct gp_segment_id) from table_for_expand;
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_expand'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_expand'::regclass;
alter table table_for_expand expand table;
select count(distinct gp_segment_id) from table_for_expand;
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_expand'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_expand'::regclass;
select gp_debug_reset_create_table_default_numsegments();
@@ -103,7 +103,7 @@ update table_for_iud set j = 'heroes never die' where i >= 300;
release savepoint level3;
commit;
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_live_tup, n_dead_tup from pg_stat_all_tables_internal where relid = 'table_for_iud'::regclass;
+select n_live_tup, n_dead_tup from pg_stat_all_tables where relid = 'table_for_iud'::regclass;
begin;
savepoint level1;
@@ -120,14 +120,14 @@ rollback to savepoint level3;
delete from table_for_iud where i <= 200;
commit;
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_live_tup, n_dead_tup from pg_stat_all_tables_internal where relid = 'table_for_iud'::regclass;
+select n_live_tup, n_dead_tup from pg_stat_all_tables where relid = 'table_for_iud'::regclass;
-- Test pgstat table stat in TRUNCATE on QD
create table table_for_truncate(i int, j varchar) distributed by (i);
insert into table_for_truncate select i, 'hello' || i from generate_series(1, 777) f(i);
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_truncate'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_truncate'::regclass;
begin;
savepoint level1;
savepoint level2;
@@ -141,12 +141,12 @@ delete from table_for_truncate where i >= 700;
update table_for_truncate set j = 'D' where i <= 200;
commit;
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_live_tup, n_dead_tup from pg_stat_all_tables_internal where relid = 'table_for_truncate'::regclass;
+select n_live_tup, n_dead_tup from pg_stat_all_tables where relid = 'table_for_truncate'::regclass;
create table table_for_truncate_abort(i int, j varchar) distributed by (i);
insert into table_for_truncate_abort select i, 'hello' || i from generate_series(1, 777) f(i);
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_live_tup, n_dead_tup from pg_stat_all_tables_internal where relid = 'table_for_truncate_abort'::regclass;
+select n_live_tup, n_dead_tup from pg_stat_all_tables where relid = 'table_for_truncate_abort'::regclass;
begin;
savepoint level1;
savepoint level2;
@@ -160,7 +160,7 @@ delete from table_for_truncate_abort where i < 700;
update table_for_truncate_abort set j = 'D' where i >= 200;
rollback;
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_live_tup, n_dead_tup from pg_stat_all_tables_internal where relid = 'table_for_truncate_abort'::regclass;
+select n_live_tup, n_dead_tup from pg_stat_all_tables where relid = 'table_for_truncate_abort'::regclass;
-- Test pgstat table stat for partition table on QD
@@ -171,17 +171,17 @@ PARTITION BY RANGE (rank)
DEFAULT PARTITION extra );
insert into rankpart select i, i % 10, i from generate_series(1, 1000)i;
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_2'::regclass;
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_3'::regclass;
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_extra'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_2'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_3'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_extra'::regclass;
begin;
delete from rankpart where id <= 100;
rollback;
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_2'::regclass;
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_3'::regclass;
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_extra'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_2'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_3'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_extra'::regclass;
copy rankpart (id, rank, product) from stdin;
1001 1 1001
@@ -196,8 +196,8 @@ copy rankpart (id, rank, product) from stdin;
1010 6 1010
\.
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_2'::regclass;
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_3'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_2'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_3'::regclass;
begin;
update rankpart set rank = 1 where id > 1005;
@@ -209,9 +209,9 @@ release savepoint level2;
rollback to savepoint level1;
commit;
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_2'::regclass;
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_3'::regclass;
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_extra'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_2'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_3'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_extra'::regclass;
begin;
savepoint level1_1;
@@ -219,9 +219,9 @@ insert into rankpart select i, i % 10, i from generate_series(2001, 3000)i;
insert into rankpart select i, i % 10, i from generate_series(3001, 4000)i;
commit;
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_2'::regclass;
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_3'::regclass;
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_extra'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_2'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_3'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_extra'::regclass;
-- Test pgstat matview stat with distributed policy.
@@ -229,11 +229,11 @@ create table base_table(i int, j int, z int ) distributed by (i);
insert into base_table select i,i,i from generate_series(1, 100) i;
create materialized view mt as select * from base_table where z>=50;
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'mt'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'mt'::regclass;
insert into base_table select i,i,i from generate_series(1, 100) i;
refresh materialized view mt;
select pg_sleep(0.77) from gp_dist_random('gp_id'); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'mt'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'mt'::regclass;
-- pg_stat_all_tables collects gpstats across segments
select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'mt'::regclass;
@@ -245,11 +245,11 @@ create table base_table(i int, j int, z int ) distributed replicated;
insert into base_table select i,i,i from generate_series(1, 100) i;
create materialized view mt as select * from base_table where z>=50 distributed replicated;
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'mt'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'mt'::regclass;
insert into base_table select i,i,i from generate_series(1, 100) i;
refresh materialized view mt;
select pg_sleep(0.77) from gp_dist_random('gp_id'); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'mt'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'mt'::regclass;
-- pg_stat_all_tables collects gpstats across segments
select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'mt'::regclass;
@@ -263,15 +263,15 @@ insert into tabstat_ao select 1,1;
delete from tabstat_ao;
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select count(*) from pg_stat_all_tables
+select count(*) from gp_stat_all_tables_summary
where
relid = (select segrelid from pg_appendonly where relid = 'tabstat_ao'::regclass)
OR relid = (select blkdirrelid from pg_appendonly where relid = 'tabstat_ao'::regclass)
OR relid = (select visimaprelid from pg_appendonly where relid = 'tabstat_ao'::regclass);
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins from pg_stat_all_tables where relid = (select segrelid from pg_appendonly where relid = 'tabstat_ao'::regclass);
-select n_tup_ins from pg_stat_all_tables where relid = (select blkdirrelid from pg_appendonly where relid = 'tabstat_ao'::regclass);
-select n_tup_ins from pg_stat_all_tables where relid = (select visimaprelid from pg_appendonly where relid = 'tabstat_ao'::regclass);
+select n_tup_ins from gp_stat_all_tables_summary where relid = (select segrelid from pg_appendonly where relid = 'tabstat_ao'::regclass);
+select n_tup_ins from gp_stat_all_tables_summary where relid = (select blkdirrelid from pg_appendonly where relid = 'tabstat_ao'::regclass);
+select n_tup_ins from gp_stat_all_tables_summary where relid = (select visimaprelid from pg_appendonly where relid = 'tabstat_ao'::regclass);
drop table tabstat_ao;
diff --git a/src/test/regress/output/pgstat_qd_tabstat.source b/src/test/regress/output/pgstat_qd_tabstat.source
index ca612e18b9c..591f262f7c5 100644
--- a/src/test/regress/output/pgstat_qd_tabstat.source
+++ b/src/test/regress/output/pgstat_qd_tabstat.source
@@ -10,7 +10,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_docopy'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_docopy'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
3 | 0 | 0 | 0 | 3 | 0 | 3
@@ -32,7 +32,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'copy_on_segment'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'copy_on_segment'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
4 | 0 | 0 | 0 | 4 | 0 | 4
@@ -70,7 +70,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_initplan'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_initplan'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
3 | 1 | 0 | 0 | 3 | 1 | 4
@@ -86,7 +86,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_ctas'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_ctas'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
100 | 0 | 0 | 0 | 100 | 0 | 100
@@ -101,7 +101,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_insert_into'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_insert_into'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
100 | 0 | 0 | 0 | 100 | 0 | 100
@@ -116,7 +116,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_set_distributed_by'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_set_distributed_by'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
333 | 0 | 0 | 0 | 333 | 0 | 333
@@ -129,7 +129,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_set_distributed_by'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_set_distributed_by'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
333 | 0 | 0 | 0 | 333 | 0 | 333
@@ -157,7 +157,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_function'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_function'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
333 | 0 | 200 | 0 | 133 | 200 | 533
@@ -185,7 +185,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_expand'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_expand'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
333 | 0 | 0 | 0 | 333 | 0 | 333
@@ -204,7 +204,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_expand'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_expand'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
333 | 0 | 0 | 0 | 333 | 0 | 333
@@ -238,7 +238,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_live_tup, n_dead_tup from pg_stat_all_tables_internal where relid = 'table_for_iud'::regclass;
+select n_live_tup, n_dead_tup from pg_stat_all_tables where relid = 'table_for_iud'::regclass;
n_live_tup | n_dead_tup
------------+------------
333 | 34
@@ -264,7 +264,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_live_tup, n_dead_tup from pg_stat_all_tables_internal where relid = 'table_for_iud'::regclass;
+select n_live_tup, n_dead_tup from pg_stat_all_tables where relid = 'table_for_iud'::regclass;
n_live_tup | n_dead_tup
------------+------------
133 | 713
@@ -279,7 +279,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_truncate'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_truncate'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
777 | 0 | 0 | 0 | 777 | 0 | 777
@@ -303,7 +303,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_live_tup, n_dead_tup from pg_stat_all_tables_internal where relid = 'table_for_truncate'::regclass;
+select n_live_tup, n_dead_tup from pg_stat_all_tables where relid = 'table_for_truncate'::regclass;
n_live_tup | n_dead_tup
------------+------------
699 | 301
@@ -317,7 +317,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_live_tup, n_dead_tup from pg_stat_all_tables_internal where relid = 'table_for_truncate_abort'::regclass;
+select n_live_tup, n_dead_tup from pg_stat_all_tables where relid = 'table_for_truncate_abort'::regclass;
n_live_tup | n_dead_tup
------------+------------
777 | 0
@@ -341,7 +341,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_live_tup, n_dead_tup from pg_stat_all_tables_internal where relid = 'table_for_truncate_abort'::regclass;
+select n_live_tup, n_dead_tup from pg_stat_all_tables where relid = 'table_for_truncate_abort'::regclass;
n_live_tup | n_dead_tup
------------+------------
777 | 223
@@ -360,19 +360,19 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_2'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_2'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
500 | 0 | 0 | 0 | 500 | 0 | 500
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_3'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_3'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
400 | 0 | 0 | 0 | 400 | 0 | 400
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_extra'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_extra'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
100 | 0 | 0 | 0 | 100 | 0 | 100
@@ -387,19 +387,19 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_2'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_2'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
500 | 0 | 50 | 0 | 500 | 0 | 500
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_3'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_3'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
400 | 0 | 40 | 0 | 400 | 0 | 400
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_extra'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_extra'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
100 | 0 | 10 | 0 | 100 | 0 | 100
@@ -412,13 +412,13 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_2'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_2'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
505 | 0 | 50 | 0 | 505 | 0 | 505
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_3'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_3'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
405 | 0 | 40 | 0 | 405 | 0 | 405
@@ -439,19 +439,19 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_2'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_2'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
510 | 0 | 55 | 0 | 510 | 0 | 510
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_3'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_3'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
410 | 0 | 50 | 0 | 400 | 10 | 410
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_extra'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_extra'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
100 | 0 | 10 | 0 | 100 | 0 | 100
@@ -468,19 +468,19 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_2'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_2'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
1510 | 0 | 55 | 0 | 1510 | 0 | 1510
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_3'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_3'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
1210 | 0 | 50 | 0 | 1200 | 10 | 1210
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_extra'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_extra'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
300 | 0 | 10 | 0 | 300 | 0 | 300
@@ -498,7 +498,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'mt'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'mt'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
51 | 0 | 0 | 0 | 51 | 0 | 51
@@ -514,7 +514,7 @@ select pg_sleep(0.77) from gp_dist_random('gp_id'); -- Force pgstat_report_stat(
(3 rows)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'mt'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'mt'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
153 | 0 | 0 | 0 | 102 | 0 | 153
@@ -539,7 +539,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'mt'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'mt'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
51 | 0 | 0 | 0 | 51 | 0 | 51
@@ -555,7 +555,7 @@ select pg_sleep(0.77) from gp_dist_random('gp_id'); -- Force pgstat_report_stat(
(3 rows)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'mt'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'mt'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
153 | 0 | 0 | 0 | 102 | 0 | 153
@@ -580,7 +580,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select count(*) from pg_stat_all_tables
+select count(*) from gp_stat_all_tables_summary
where
relid = (select segrelid from pg_appendonly where relid = 'tabstat_ao'::regclass)
OR relid = (select blkdirrelid from pg_appendonly where relid = 'tabstat_ao'::regclass)
@@ -596,19 +596,19 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins from pg_stat_all_tables where relid = (select segrelid from pg_appendonly where relid = 'tabstat_ao'::regclass);
+select n_tup_ins from gp_stat_all_tables_summary where relid = (select segrelid from pg_appendonly where relid = 'tabstat_ao'::regclass);
n_tup_ins
-----------
1
(1 row)
-select n_tup_ins from pg_stat_all_tables where relid = (select blkdirrelid from pg_appendonly where relid = 'tabstat_ao'::regclass);
+select n_tup_ins from gp_stat_all_tables_summary where relid = (select blkdirrelid from pg_appendonly where relid = 'tabstat_ao'::regclass);
n_tup_ins
-----------
1
(1 row)
-select n_tup_ins from pg_stat_all_tables where relid = (select visimaprelid from pg_appendonly where relid = 'tabstat_ao'::regclass);
+select n_tup_ins from gp_stat_all_tables_summary where relid = (select visimaprelid from pg_appendonly where relid = 'tabstat_ao'::regclass);
n_tup_ins
-----------
1
diff --git a/src/test/regress/sql/pg_stat.sql b/src/test/regress/sql/pg_stat.sql
index d9fc37850b0..383a9149186 100644
--- a/src/test/regress/sql/pg_stat.sql
+++ b/src/test/regress/sql/pg_stat.sql
@@ -6,17 +6,17 @@ create table pg_stat_test(a int);
select
schemaname, relname, seq_scan, seq_tup_read, idx_scan, idx_tup_fetch, n_tup_ins, n_tup_upd,
n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup
-from pg_stat_all_tables where relname = 'pg_stat_test';
+from gp_stat_all_tables_summary where relname = 'pg_stat_test';
select
schemaname, relname, seq_scan, seq_tup_read, idx_scan, idx_tup_fetch, n_tup_ins, n_tup_upd,
n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup
-from pg_stat_user_tables where relname = 'pg_stat_test';
+from gp_stat_user_tables_summary where relname = 'pg_stat_test';
select
schemaname, relname, indexrelname, idx_scan, idx_tup_read, idx_tup_fetch
-from pg_stat_all_indexes where relname = 'pg_stat_test';
+from gp_stat_all_indexes_summary where relname = 'pg_stat_test';
select
schemaname, relname, indexrelname, idx_scan, idx_tup_read, idx_tup_fetch
-from pg_stat_user_indexes where relname = 'pg_stat_test';
+from gp_stat_user_indexes_summary where relname = 'pg_stat_test';
begin; -- make analyze same transcation with insert to avoid double the pgstat causes by unorder message read.
insert into pg_stat_test select * from generate_series(1, 100);
@@ -42,17 +42,17 @@ reset enable_seqscan;
select
schemaname, relname, seq_scan, seq_tup_read, idx_scan, idx_tup_fetch, n_tup_ins, n_tup_upd,
n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze
-from pg_stat_all_tables where relname = 'pg_stat_test';
+from gp_stat_all_tables_summary where relname = 'pg_stat_test';
select
schemaname, relname, seq_scan, seq_tup_read, idx_scan, idx_tup_fetch, n_tup_ins, n_tup_upd,
n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze
-from pg_stat_user_tables where relname = 'pg_stat_test';
+from gp_stat_user_tables_summary where relname = 'pg_stat_test';
select
schemaname, relname, indexrelname, idx_scan, idx_tup_read, idx_tup_fetch
-from pg_stat_all_indexes where relname = 'pg_stat_test';
+from gp_stat_all_indexes_summary where relname = 'pg_stat_test';
select
schemaname, relname, indexrelname, idx_scan, idx_tup_read, idx_tup_fetch
-from pg_stat_user_indexes where relname = 'pg_stat_test';
+from gp_stat_user_indexes_summary where relname = 'pg_stat_test';
reset optimizer;
reset max_parallel_workers_per_gather;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org
(cloudberry) 04/04: Fix: Adapt system view after cherry-pick
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
maxyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git
commit 05869c862a5f788558c720db123171ed60eaa067
Author: liushengsong <li...@hashdata.cn>
AuthorDate: Wed Sep 3 11:33:49 2025 +0800
Fix: Adapt system view after cherry-pick
---
configure.ac | 2 +-
.../expected/auto_explain_optimizer.out | 2 +-
.../isolation2/input/autovacuum-analyze.source | 12 +-
.../isolation2/output/autovacuum-analyze.source | 12 +-
.../src/test/regress/expected/pg_stat.out | 16 +-
.../src/test/regress/expected/stats.out | 14 +-
.../test/regress/input/pgstat_qd_tabstat.source | 80 ++---
.../test/regress/output/pgstat_qd_tabstat.source | 84 +++---
.../pax_storage/src/test/regress/sql/pg_stat.sql | 16 +-
contrib/pax_storage/src/test/regress/sql/stats.sql | 14 +-
src/backend/catalog/system_views.sql | 29 +-
src/backend/catalog/system_views_gp.in | 20 +-
src/backend/catalog/system_views_gp_summary.sql | 1 +
src/test/isolation2/expected/analyze_progress.out | 1 -
.../expected/ao_index_build_progress.out | 4 +-
.../isolation2/expected/vacuum_progress_column.out | 83 ++----
.../isolation2/expected/vacuum_progress_row.out | 327 ++++++++++++++-------
.../isolation2/input/autovacuum-analyze.source | 12 +-
.../isolation2/output/autovacuum-analyze.source | 12 +-
.../output/parallel_retrieve_cursor/explain.source | 19 +-
src/test/isolation2/sql/setup.sql | 21 --
src/test/isolation2/sql/vacuum_progress_column.sql | 21 +-
src/test/isolation2/sql/vacuum_progress_row.sql | 82 +++++-
src/test/regress/expected/stats.out | 14 +-
src/test/regress/input/pgstat_qd_tabstat.source | 8 +-
src/test/regress/output/pgstat_qd_tabstat.source | 8 +-
src/test/regress/sql/stats.sql | 14 +-
27 files changed, 514 insertions(+), 414 deletions(-)
diff --git a/configure.ac b/configure.ac
index 890e8437cdf..0d0529fc35f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,7 +20,7 @@ m4_pattern_forbid(^PGAC_)dnl to catch undefined macros
dnl The PACKAGE_VERSION from upstream PostgreSQL is maintained in the
dnl PG_PACKAGE_VERSION variable, when merging make sure to update this
dnl variable with the merge conflict from the AC_INIT() statement.
-AC_INIT([Apache Cloudberry], [2.1.0-devel], [dev@cloudberry.apache.org], [], [https://cloudberry.apache.org/])
+AC_INIT([Apache Cloudberry], [3.0.0-devel], [dev@cloudberry.apache.org], [], [https://cloudberry.apache.org/])
[PG_PACKAGE_VERSION=14.4]
AC_SUBST(PG_PACKAGE_VERSION)
diff --git a/contrib/auto_explain/expected/auto_explain_optimizer.out b/contrib/auto_explain/expected/auto_explain_optimizer.out
index e1d3e334d95..1f469cc45fc 100644
--- a/contrib/auto_explain/expected/auto_explain_optimizer.out
+++ b/contrib/auto_explain/expected/auto_explain_optimizer.out
@@ -38,7 +38,7 @@ LOG: duration: 0.026 ms plan:
Query Text: SELECT relname FROM pg_class WHERE relname='pg_class';
Index Only Scan using pg_class_relname_nsp_index on pg_class (cost=0.15..4.17 rows=1 width=64) (actual rows=1 loops=1)
Index Cond: (relname = 'pg_class'::name)
- Heap Fetches: 1
+ Heap Fetches: 0
(slice0) Executor memory: 105K bytes.
Memory used: 128000kB
relname
diff --git a/contrib/pax_storage/src/test/isolation2/input/autovacuum-analyze.source b/contrib/pax_storage/src/test/isolation2/input/autovacuum-analyze.source
index 32e79cdd491..19187b107c2 100644
--- a/contrib/pax_storage/src/test/isolation2/input/autovacuum-analyze.source
+++ b/contrib/pax_storage/src/test/isolation2/input/autovacuum-analyze.source
@@ -178,7 +178,7 @@ SELECT count(*) FROM pg_statistic where starelid = 'autostatstbl'::regclass;
select relpages, reltuples from pg_class where oid = 'autostatstbl'::regclass;
-- expect analyze_count = 1, autoanalyze_count = 0, and n_mod_since_analyze = 1000 since ANALYZE executed
-- in same transaction for the insert statement.
-select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables_internal where relname = 'autostatstbl';
+select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables where relname = 'autostatstbl';
-- Wait until autovacuum is triggered
SELECT gp_wait_until_triggered_fault('auto_vac_worker_after_report_activity', 1, 1);
@@ -192,7 +192,7 @@ SELECT gp_inject_fault('analyze_finished_one_relation', 'reset', 1);
-- we can see the auto-ANALYZE finished
select relpages, reltuples from pg_class where oid = 'autostatstbl'::regclass;
-- expect analyze_count = 1, autoanalyze_count = 1, and n_mod_since_analyze = 0
-select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables_internal where relname = 'autostatstbl';
+select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables where relname = 'autostatstbl';
-- Case 2 --
-- with auto_stats 'on_change' mode, the auto-ANALYZE still trigger
@@ -211,7 +211,7 @@ SELECT gp_inject_fault('auto_vac_worker_after_report_activity', 'suspend', '', '
select relpages, reltuples from pg_class where oid = 'autostatstbl'::regclass;
-- expect analyze_count = 2, autoanalyze_count = 1, and n_mod_since_analyze = 1000 since ANALYZE executed
-- in same transaction for the insert statement.
-select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables_internal where relname = 'autostatstbl';
+select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables where relname = 'autostatstbl';
-- Wait until autovacuum is triggered
SELECT gp_wait_until_triggered_fault('auto_vac_worker_after_report_activity', 1, 1);
@@ -225,7 +225,7 @@ SELECT gp_inject_fault('analyze_finished_one_relation', 'reset', 1);
-- we can see the auto-ANALYZE finished, check statistic and analyze count
select relpages, reltuples from pg_class where oid = 'autostatstbl'::regclass;
-- expect analyze_count = 2, autoanalyze_count = 2, and n_mod_since_analyze = 0
-select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables_internal where relname = 'autostatstbl';
+select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables where relname = 'autostatstbl';
-- Case 3 --
@@ -244,7 +244,7 @@ SELECT gp_inject_fault('auto_vac_worker_after_report_activity', 'suspend', '', '
select relpages, reltuples from pg_class where oid = 'autostatstbl'::regclass;
-- expect analyze_count = 2, autoanalyze_count = 2, and n_mod_since_analyze = 1000 since ANALYZE executed
-- in same transaction for the insert statement.
-select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables_internal where relname = 'autostatstbl';
+select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables where relname = 'autostatstbl';
-- Wait until autovacuum is triggered
SELECT gp_wait_until_triggered_fault('auto_vac_worker_after_report_activity', 1, 1);
@@ -258,7 +258,7 @@ SELECT gp_inject_fault('analyze_finished_one_relation', 'reset', 1);
-- we can see the auto-ANALYZE finished, check statistic and analyze count
select relpages, reltuples from pg_class where oid = 'autostatstbl'::regclass;
-- expect analyze_count = 2, autoanalyze_count = 3, and n_mod_since_analyze = 0 since ANALYZE executed
-select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables_internal where relname = 'autostatstbl';
+select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables where relname = 'autostatstbl';
-- Reset GUCs.
ALTER SYSTEM RESET autovacuum_naptime;
diff --git a/contrib/pax_storage/src/test/isolation2/output/autovacuum-analyze.source b/contrib/pax_storage/src/test/isolation2/output/autovacuum-analyze.source
index 0c4b87746e4..dff55111b64 100644
--- a/contrib/pax_storage/src/test/isolation2/output/autovacuum-analyze.source
+++ b/contrib/pax_storage/src/test/isolation2/output/autovacuum-analyze.source
@@ -422,7 +422,7 @@ select relpages, reltuples from pg_class where oid = 'autostatstbl'::regclass;
(1 row)
-- expect analyze_count = 1, autoanalyze_count = 0, and n_mod_since_analyze = 1000 since ANALYZE executed
-- in same transaction for the insert statement.
-select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables_internal where relname = 'autostatstbl';
+select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables where relname = 'autostatstbl';
analyze_count | autoanalyze_count | n_mod_since_analyze
---------------+-------------------+---------------------
1 | 0 | 1000
@@ -465,7 +465,7 @@ select relpages, reltuples from pg_class where oid = 'autostatstbl'::regclass;
1 | 1000
(1 row)
-- expect analyze_count = 1, autoanalyze_count = 1, and n_mod_since_analyze = 0
-select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables_internal where relname = 'autostatstbl';
+select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables where relname = 'autostatstbl';
analyze_count | autoanalyze_count | n_mod_since_analyze
---------------+-------------------+---------------------
1 | 1 | 0
@@ -502,7 +502,7 @@ select relpages, reltuples from pg_class where oid = 'autostatstbl'::regclass;
(1 row)
-- expect analyze_count = 2, autoanalyze_count = 1, and n_mod_since_analyze = 1000 since ANALYZE executed
-- in same transaction for the insert statement.
-select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables_internal where relname = 'autostatstbl';
+select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables where relname = 'autostatstbl';
analyze_count | autoanalyze_count | n_mod_since_analyze
---------------+-------------------+---------------------
2 | 1 | 1000
@@ -545,7 +545,7 @@ select relpages, reltuples from pg_class where oid = 'autostatstbl'::regclass;
1 | 2000
(1 row)
-- expect analyze_count = 2, autoanalyze_count = 2, and n_mod_since_analyze = 0
-select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables_internal where relname = 'autostatstbl';
+select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables where relname = 'autostatstbl';
analyze_count | autoanalyze_count | n_mod_since_analyze
---------------+-------------------+---------------------
2 | 2 | 0
@@ -581,7 +581,7 @@ select relpages, reltuples from pg_class where oid = 'autostatstbl'::regclass;
(1 row)
-- expect analyze_count = 2, autoanalyze_count = 2, and n_mod_since_analyze = 1000 since ANALYZE executed
-- in same transaction for the insert statement.
-select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables_internal where relname = 'autostatstbl';
+select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables where relname = 'autostatstbl';
analyze_count | autoanalyze_count | n_mod_since_analyze
---------------+-------------------+---------------------
2 | 2 | 1000
@@ -624,7 +624,7 @@ select relpages, reltuples from pg_class where oid = 'autostatstbl'::regclass;
1 | 3000
(1 row)
-- expect analyze_count = 2, autoanalyze_count = 3, and n_mod_since_analyze = 0 since ANALYZE executed
-select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables_internal where relname = 'autostatstbl';
+select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables where relname = 'autostatstbl';
analyze_count | autoanalyze_count | n_mod_since_analyze
---------------+-------------------+---------------------
2 | 3 | 0
diff --git a/contrib/pax_storage/src/test/regress/expected/pg_stat.out b/contrib/pax_storage/src/test/regress/expected/pg_stat.out
index 27dc25f957d..761372051ef 100644
--- a/contrib/pax_storage/src/test/regress/expected/pg_stat.out
+++ b/contrib/pax_storage/src/test/regress/expected/pg_stat.out
@@ -5,7 +5,7 @@ create table pg_stat_test(a int);
select
schemaname, relname, seq_scan, seq_tup_read, idx_scan, idx_tup_fetch, n_tup_ins, n_tup_upd,
n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup
-from pg_stat_all_tables where relname = 'pg_stat_test';
+from gp_stat_all_tables_summary where relname = 'pg_stat_test';
schemaname | relname | seq_scan | seq_tup_read | idx_scan | idx_tup_fetch | n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup
------------+--------------+----------+--------------+----------+---------------+-----------+-----------+-----------+---------------+------------+------------
public | pg_stat_test | 0 | 0 | | | 0 | 0 | 0 | 0 | 0 | 0
@@ -14,7 +14,7 @@ from pg_stat_all_tables where relname = 'pg_stat_test';
select
schemaname, relname, seq_scan, seq_tup_read, idx_scan, idx_tup_fetch, n_tup_ins, n_tup_upd,
n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup
-from pg_stat_user_tables where relname = 'pg_stat_test';
+from gp_stat_user_tables_summary where relname = 'pg_stat_test';
schemaname | relname | seq_scan | seq_tup_read | idx_scan | idx_tup_fetch | n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup
------------+--------------+----------+--------------+----------+---------------+-----------+-----------+-----------+---------------+------------+------------
public | pg_stat_test | 0 | 0 | | | 0 | 0 | 0 | 0 | 0 | 0
@@ -22,14 +22,14 @@ from pg_stat_user_tables where relname = 'pg_stat_test';
select
schemaname, relname, indexrelname, idx_scan, idx_tup_read, idx_tup_fetch
-from pg_stat_all_indexes where relname = 'pg_stat_test';
+from gp_stat_all_indexes_summary where relname = 'pg_stat_test';
schemaname | relname | indexrelname | idx_scan | idx_tup_read | idx_tup_fetch
------------+---------+--------------+----------+--------------+---------------
(0 rows)
select
schemaname, relname, indexrelname, idx_scan, idx_tup_read, idx_tup_fetch
-from pg_stat_user_indexes where relname = 'pg_stat_test';
+from gp_stat_user_indexes_summary where relname = 'pg_stat_test';
schemaname | relname | indexrelname | idx_scan | idx_tup_read | idx_tup_fetch
------------+---------+--------------+----------+--------------+---------------
(0 rows)
@@ -63,7 +63,7 @@ reset enable_seqscan;
select
schemaname, relname, seq_scan, seq_tup_read, idx_scan, idx_tup_fetch, n_tup_ins, n_tup_upd,
n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze
-from pg_stat_all_tables where relname = 'pg_stat_test';
+from gp_stat_all_tables_summary where relname = 'pg_stat_test';
schemaname | relname | seq_scan | seq_tup_read | idx_scan | idx_tup_fetch | n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
------------+--------------+----------+--------------+----------+---------------+-----------+-----------+-----------+---------------+------------+------------+---------------------
public | pg_stat_test | 15 | 391 | 1 | 0 | 110 | 0 | 19 | 0 | 91 | 19 | 129
@@ -72,7 +72,7 @@ from pg_stat_all_tables where relname = 'pg_stat_test';
select
schemaname, relname, seq_scan, seq_tup_read, idx_scan, idx_tup_fetch, n_tup_ins, n_tup_upd,
n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze
-from pg_stat_user_tables where relname = 'pg_stat_test';
+from gp_stat_user_tables_summary where relname = 'pg_stat_test';
schemaname | relname | seq_scan | seq_tup_read | idx_scan | idx_tup_fetch | n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
------------+--------------+----------+--------------+----------+---------------+-----------+-----------+-----------+---------------+------------+------------+---------------------
public | pg_stat_test | 15 | 391 | 1 | 0 | 110 | 0 | 19 | 0 | 91 | 19 | 129
@@ -80,7 +80,7 @@ from pg_stat_user_tables where relname = 'pg_stat_test';
select
schemaname, relname, indexrelname, idx_scan, idx_tup_read, idx_tup_fetch
-from pg_stat_all_indexes where relname = 'pg_stat_test';
+from gp_stat_all_indexes_summary where relname = 'pg_stat_test';
schemaname | relname | indexrelname | idx_scan | idx_tup_read | idx_tup_fetch
------------+--------------+--------------------------+----------+--------------+---------------
public | pg_stat_test | pg_stat_user_table_index | 1 | 1 | 0
@@ -88,7 +88,7 @@ from pg_stat_all_indexes where relname = 'pg_stat_test';
select
schemaname, relname, indexrelname, idx_scan, idx_tup_read, idx_tup_fetch
-from pg_stat_user_indexes where relname = 'pg_stat_test';
+from gp_stat_user_indexes_summary where relname = 'pg_stat_test';
schemaname | relname | indexrelname | idx_scan | idx_tup_read | idx_tup_fetch
------------+--------------+--------------------------+----------+--------------+---------------
public | pg_stat_test | pg_stat_user_table_index | 1 | 1 | 0
diff --git a/contrib/pax_storage/src/test/regress/expected/stats.out b/contrib/pax_storage/src/test/regress/expected/stats.out
index d3f407656fc..a75f9801a36 100644
--- a/contrib/pax_storage/src/test/regress/expected/stats.out
+++ b/contrib/pax_storage/src/test/regress/expected/stats.out
@@ -22,7 +22,7 @@ SELECT t.seq_scan, t.seq_tup_read, t.idx_scan, t.idx_tup_fetch,
(b.heap_blks_read + b.heap_blks_hit) AS heap_blks,
(b.idx_blks_read + b.idx_blks_hit) AS idx_blks,
pg_stat_get_snapshot_timestamp() as snap_ts
- FROM pg_catalog.pg_stat_user_tables AS t,
+ FROM pg_catalog.gp_stat_user_tables_summary AS t,
pg_catalog.pg_statio_user_tables AS b
WHERE t.relname='tenk2' AND b.relname='tenk2';
-- function to wait for counters to advance
@@ -45,17 +45,17 @@ begin
-- check to see if seqscan has been sensed
SELECT (st.seq_scan >= pr.seq_scan + 1) INTO updated1
- FROM pg_stat_user_tables AS st, pg_class AS cl, prevstats AS pr
+ FROM gp_stat_user_tables_summary AS st, pg_class AS cl, prevstats AS pr
WHERE st.relname='tenk2' AND cl.relname='tenk2';
-- check to see if indexscan has been sensed
SELECT (st.idx_scan >= pr.idx_scan + 1) INTO updated2
- FROM pg_stat_user_tables AS st, pg_class AS cl, prevstats AS pr
+ FROM gp_stat_user_tables_summary AS st, pg_class AS cl, prevstats AS pr
WHERE st.relname='tenk2' AND cl.relname='tenk2';
-- check to see if all updates have been sensed
SELECT (n_tup_ins > 0) INTO updated3
- FROM pg_stat_user_tables WHERE relname='trunc_stats_test4';
+ FROM gp_stat_user_tables_summary WHERE relname='trunc_stats_test4';
-- We must also check explicitly that pg_stat_get_snapshot_timestamp has
-- advanced, because that comes from the global stats file which might
@@ -65,7 +65,7 @@ begin
-- check to see if idx_tup_fetch has been sensed
SELECT (st.idx_tup_fetch >= pr.idx_tup_fetch + 1) INTO updated5
- FROM pg_stat_user_tables AS st, pg_class AS cl, prevstats AS pr
+ FROM gp_stat_user_tables_summary AS st, pg_class AS cl, prevstats AS pr
WHERE st.relname='tenk2' AND cl.relname='tenk2';
exit when updated1 and updated2 and updated3 and updated4 and updated5;
@@ -177,7 +177,7 @@ SELECT wait_for_stats();
-- check effects
SELECT relname, n_tup_ins, n_tup_upd, n_tup_del, n_live_tup, n_dead_tup
- FROM pg_stat_user_tables
+ FROM gp_stat_user_tables_summary
WHERE relname like 'trunc_stats_test%' order by relname;
relname | n_tup_ins | n_tup_upd | n_tup_del | n_live_tup | n_dead_tup
-------------------+-----------+-----------+-----------+------------+------------
@@ -192,7 +192,7 @@ SELECT st.seq_scan >= pr.seq_scan + 1,
st.seq_tup_read >= pr.seq_tup_read + cl.reltuples,
st.idx_scan >= pr.idx_scan + 1,
st.idx_tup_fetch >= pr.idx_tup_fetch + 1
- FROM pg_stat_user_tables AS st, pg_class AS cl, prevstats AS pr
+ FROM gp_stat_user_tables_summary AS st, pg_class AS cl, prevstats AS pr
WHERE st.relname='tenk2' AND cl.relname='tenk2';
?column? | ?column? | ?column? | ?column?
----------+----------+----------+----------
diff --git a/contrib/pax_storage/src/test/regress/input/pgstat_qd_tabstat.source b/contrib/pax_storage/src/test/regress/input/pgstat_qd_tabstat.source
index a3c201de66c..4be0a8c7eb8 100644
--- a/contrib/pax_storage/src/test/regress/input/pgstat_qd_tabstat.source
+++ b/contrib/pax_storage/src/test/regress/input/pgstat_qd_tabstat.source
@@ -10,7 +10,7 @@ copy table_for_docopy (i, j) from stdin;
3 hello3
\.
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_docopy'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_docopy'::regclass;
CREATE TABLE data_tbl (a int,b char) distributed by (a);
INSERT INTO data_tbl values(1,'1');
@@ -21,7 +21,7 @@ COPY data_tbl TO '/tmp/data_tbl<SEGID>.csv' on segment;
create table copy_on_segment (a int,b char);
COPY copy_on_segment from '/tmp/data_tbl<SEGID>.csv' on segment log errors segment reject limit 3 rows;
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'copy_on_segment'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'copy_on_segment'::regclass;
-- Test pgstat table stat in initplan on QD
@@ -34,26 +34,26 @@ copy table_for_initplan (i, j, k) from stdin;
explain (costs off) with updated AS (update table_for_initplan set k = 33 where i = 3 returning k) select table_for_initplan.*, (select sum(k) from updated) from table_for_initplan;
with updated AS (update table_for_initplan set k = 33 where i = 3 returning k) select table_for_initplan.*, (select sum(k) from updated) from table_for_initplan;
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_initplan'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_initplan'::regclass;
-- Test pgstat table stat in CTAS on QD
create table table_for_ctas as select i, 'hello' || i from generate_series(1, 100) f(i);
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_ctas'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_ctas'::regclass;
select i, 'hello' || i into table_for_insert_into from generate_series(1, 100) f(i);
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_insert_into'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_insert_into'::regclass;
-- Test pgstat table stat in ALTER TABLE SET DISTRIBUTED BY on QD
create table table_for_set_distributed_by(i int, j varchar) distributed by (i);
insert into table_for_set_distributed_by select i, 'hello' || i from generate_series(1, 333) f(i);
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_set_distributed_by'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_set_distributed_by'::regclass;
alter table table_for_set_distributed_by set distributed by (j);
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_set_distributed_by'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_set_distributed_by'::regclass;
-- Test pgstat table stat in execution of funciton on QD
@@ -68,7 +68,7 @@ $$
language plpgsql volatile;
select update_table_for_function();
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_function'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_function'::regclass;
-- Test pgstat table stat in ALTER TABLE EXPAND TABLE on QD;
@@ -78,11 +78,11 @@ create table table_for_expand(i int, j varchar) distributed by (i);
insert into table_for_expand select i, 'hello' || i from generate_series(1, 333) f(i);
select count(distinct gp_segment_id) from table_for_expand;
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_expand'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_expand'::regclass;
alter table table_for_expand expand table;
select count(distinct gp_segment_id) from table_for_expand;
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_expand'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_expand'::regclass;
select gp_debug_reset_create_table_default_numsegments();
@@ -103,7 +103,7 @@ update table_for_iud set j = 'heroes never die' where i >= 300;
release savepoint level3;
commit;
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_live_tup, n_dead_tup from pg_stat_all_tables_internal where relid = 'table_for_iud'::regclass;
+select n_live_tup, n_dead_tup from pg_stat_all_tables where relid = 'table_for_iud'::regclass;
begin;
savepoint level1;
@@ -120,14 +120,14 @@ rollback to savepoint level3;
delete from table_for_iud where i <= 200;
commit;
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_live_tup, n_dead_tup from pg_stat_all_tables_internal where relid = 'table_for_iud'::regclass;
+select n_live_tup, n_dead_tup from pg_stat_all_tables where relid = 'table_for_iud'::regclass;
-- Test pgstat table stat in TRUNCATE on QD
create table table_for_truncate(i int, j varchar) distributed by (i);
insert into table_for_truncate select i, 'hello' || i from generate_series(1, 777) f(i);
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_truncate'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_truncate'::regclass;
begin;
savepoint level1;
savepoint level2;
@@ -141,12 +141,12 @@ delete from table_for_truncate where i >= 700;
update table_for_truncate set j = 'D' where i <= 200;
commit;
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_live_tup, n_dead_tup from pg_stat_all_tables_internal where relid = 'table_for_truncate'::regclass;
+select n_live_tup, n_dead_tup from pg_stat_all_tables where relid = 'table_for_truncate'::regclass;
create table table_for_truncate_abort(i int, j varchar) distributed by (i);
insert into table_for_truncate_abort select i, 'hello' || i from generate_series(1, 777) f(i);
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_live_tup, n_dead_tup from pg_stat_all_tables_internal where relid = 'table_for_truncate_abort'::regclass;
+select n_live_tup, n_dead_tup from pg_stat_all_tables where relid = 'table_for_truncate_abort'::regclass;
begin;
savepoint level1;
savepoint level2;
@@ -160,7 +160,7 @@ delete from table_for_truncate_abort where i < 700;
update table_for_truncate_abort set j = 'D' where i >= 200;
rollback;
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_live_tup, n_dead_tup from pg_stat_all_tables_internal where relid = 'table_for_truncate_abort'::regclass;
+select n_live_tup, n_dead_tup from pg_stat_all_tables where relid = 'table_for_truncate_abort'::regclass;
-- Test pgstat table stat for partition table on QD
@@ -171,17 +171,17 @@ PARTITION BY RANGE (rank)
DEFAULT PARTITION extra );
insert into rankpart select i, i % 10, i from generate_series(1, 1000)i;
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_2'::regclass;
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_3'::regclass;
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_extra'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_2'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_3'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_extra'::regclass;
begin;
delete from rankpart where id <= 100;
rollback;
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_2'::regclass;
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_3'::regclass;
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_extra'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_2'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_3'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_extra'::regclass;
copy rankpart (id, rank, product) from stdin;
1001 1 1001
@@ -196,8 +196,8 @@ copy rankpart (id, rank, product) from stdin;
1010 6 1010
\.
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_2'::regclass;
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_3'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_2'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_3'::regclass;
begin;
update rankpart set rank = 1 where id > 1005;
@@ -209,9 +209,9 @@ release savepoint level2;
rollback to savepoint level1;
commit;
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_2'::regclass;
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_3'::regclass;
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_extra'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_2'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_3'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_extra'::regclass;
begin;
savepoint level1_1;
@@ -219,9 +219,9 @@ insert into rankpart select i, i % 10, i from generate_series(2001, 3000)i;
insert into rankpart select i, i % 10, i from generate_series(3001, 4000)i;
commit;
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_2'::regclass;
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_3'::regclass;
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_extra'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_2'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_3'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_extra'::regclass;
-- Test pgstat matview stat with distributed policy.
@@ -229,13 +229,13 @@ create table base_table(i int, j int, z int ) distributed by (i);
insert into base_table select i,i,i from generate_series(1, 100) i;
create materialized view mt as select * from base_table where z>=50;
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'mt'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'mt'::regclass;
insert into base_table select i,i,i from generate_series(1, 100) i;
refresh materialized view mt;
select pg_sleep(0.77) from gp_dist_random('gp_id'); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'mt'::regclass;
--- pg_stat_all_tables collects gpstats across segments
select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'mt'::regclass;
+-- gp_stat_all_tables_summary collects gpstats across segments
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from gp_stat_all_tables_summary where relid = 'mt'::regclass;
drop materialized view mt;
drop table base_table;
@@ -245,13 +245,13 @@ create table base_table(i int, j int, z int ) distributed replicated;
insert into base_table select i,i,i from generate_series(1, 100) i;
create materialized view mt as select * from base_table where z>=50 distributed replicated;
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'mt'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'mt'::regclass;
insert into base_table select i,i,i from generate_series(1, 100) i;
refresh materialized view mt;
select pg_sleep(0.77) from gp_dist_random('gp_id'); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'mt'::regclass;
--- pg_stat_all_tables collects gpstats across segments
select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'mt'::regclass;
+-- gp_stat_all_tables_summary collects gpstats across segments
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from gp_stat_all_tables_summary where relid = 'mt'::regclass;
reset gp_autostats_mode;
@@ -263,15 +263,15 @@ insert into tabstat_ao select 1,1;
delete from tabstat_ao;
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select count(*) from pg_stat_all_tables
+select count(*) from gp_stat_all_tables_summary
where
relid = (select segrelid from pg_appendonly where relid = 'tabstat_ao'::regclass)
OR relid = (select blkdirrelid from pg_appendonly where relid = 'tabstat_ao'::regclass)
OR relid = (select visimaprelid from pg_appendonly where relid = 'tabstat_ao'::regclass);
select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
-select n_tup_ins from pg_stat_all_tables where relid = (select segrelid from pg_appendonly where relid = 'tabstat_ao'::regclass);
-select n_tup_ins from pg_stat_all_tables where relid = (select blkdirrelid from pg_appendonly where relid = 'tabstat_ao'::regclass);
-select n_tup_ins from pg_stat_all_tables where relid = (select visimaprelid from pg_appendonly where relid = 'tabstat_ao'::regclass);
+select n_tup_ins from gp_stat_all_tables_summary where relid = (select segrelid from pg_appendonly where relid = 'tabstat_ao'::regclass);
+select n_tup_ins from gp_stat_all_tables_summary where relid = (select blkdirrelid from pg_appendonly where relid = 'tabstat_ao'::regclass);
+select n_tup_ins from gp_stat_all_tables_summary where relid = (select visimaprelid from pg_appendonly where relid = 'tabstat_ao'::regclass);
drop table tabstat_ao;
diff --git a/contrib/pax_storage/src/test/regress/output/pgstat_qd_tabstat.source b/contrib/pax_storage/src/test/regress/output/pgstat_qd_tabstat.source
index 5118839b171..a0b24ee35dc 100644
--- a/contrib/pax_storage/src/test/regress/output/pgstat_qd_tabstat.source
+++ b/contrib/pax_storage/src/test/regress/output/pgstat_qd_tabstat.source
@@ -10,7 +10,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_docopy'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_docopy'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
3 | 0 | 0 | 0 | 3 | 0 | 3
@@ -32,7 +32,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'copy_on_segment'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'copy_on_segment'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
4 | 0 | 0 | 0 | 4 | 0 | 4
@@ -70,7 +70,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_initplan'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_initplan'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
3 | 1 | 0 | 0 | 3 | 1 | 4
@@ -86,7 +86,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_ctas'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_ctas'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
100 | 0 | 0 | 0 | 100 | 0 | 100
@@ -101,7 +101,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_insert_into'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_insert_into'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
100 | 0 | 0 | 0 | 100 | 0 | 100
@@ -116,7 +116,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_set_distributed_by'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_set_distributed_by'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
333 | 0 | 0 | 0 | 333 | 0 | 333
@@ -129,7 +129,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_set_distributed_by'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_set_distributed_by'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
333 | 0 | 0 | 0 | 333 | 0 | 333
@@ -157,7 +157,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_function'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_function'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
333 | 0 | 200 | 0 | 133 | 200 | 533
@@ -185,7 +185,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_expand'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_expand'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
333 | 0 | 0 | 0 | 333 | 0 | 333
@@ -204,7 +204,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_expand'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_expand'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
333 | 0 | 0 | 0 | 333 | 0 | 333
@@ -238,7 +238,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_live_tup, n_dead_tup from pg_stat_all_tables_internal where relid = 'table_for_iud'::regclass;
+select n_live_tup, n_dead_tup from pg_stat_all_tables where relid = 'table_for_iud'::regclass;
n_live_tup | n_dead_tup
------------+------------
333 | 34
@@ -264,7 +264,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_live_tup, n_dead_tup from pg_stat_all_tables_internal where relid = 'table_for_iud'::regclass;
+select n_live_tup, n_dead_tup from pg_stat_all_tables where relid = 'table_for_iud'::regclass;
n_live_tup | n_dead_tup
------------+------------
133 | 713
@@ -279,7 +279,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'table_for_truncate'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'table_for_truncate'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
777 | 0 | 0 | 0 | 777 | 0 | 777
@@ -303,7 +303,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_live_tup, n_dead_tup from pg_stat_all_tables_internal where relid = 'table_for_truncate'::regclass;
+select n_live_tup, n_dead_tup from pg_stat_all_tables where relid = 'table_for_truncate'::regclass;
n_live_tup | n_dead_tup
------------+------------
699 | 301
@@ -317,7 +317,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_live_tup, n_dead_tup from pg_stat_all_tables_internal where relid = 'table_for_truncate_abort'::regclass;
+select n_live_tup, n_dead_tup from pg_stat_all_tables where relid = 'table_for_truncate_abort'::regclass;
n_live_tup | n_dead_tup
------------+------------
777 | 0
@@ -341,7 +341,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_live_tup, n_dead_tup from pg_stat_all_tables_internal where relid = 'table_for_truncate_abort'::regclass;
+select n_live_tup, n_dead_tup from pg_stat_all_tables where relid = 'table_for_truncate_abort'::regclass;
n_live_tup | n_dead_tup
------------+------------
777 | 223
@@ -360,19 +360,19 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_2'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_2'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
500 | 0 | 0 | 0 | 500 | 0 | 500
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_3'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_3'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
400 | 0 | 0 | 0 | 400 | 0 | 400
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_extra'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_extra'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
100 | 0 | 0 | 0 | 100 | 0 | 100
@@ -387,19 +387,19 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_2'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_2'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
500 | 0 | 50 | 0 | 500 | 0 | 500
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_3'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_3'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
400 | 0 | 40 | 0 | 400 | 0 | 400
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_extra'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_extra'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
100 | 0 | 10 | 0 | 100 | 0 | 100
@@ -412,13 +412,13 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_2'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_2'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
505 | 0 | 50 | 0 | 505 | 0 | 505
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_3'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_3'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
405 | 0 | 40 | 0 | 405 | 0 | 405
@@ -439,19 +439,19 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_2'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_2'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
510 | 0 | 55 | 0 | 510 | 0 | 510
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_3'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_3'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
410 | 0 | 50 | 0 | 400 | 10 | 410
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_extra'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_extra'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
100 | 0 | 10 | 0 | 100 | 0 | 100
@@ -468,19 +468,19 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_2'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_2'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
1510 | 0 | 55 | 0 | 1510 | 0 | 1510
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_3'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_3'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
1210 | 0 | 50 | 0 | 1200 | 10 | 1210
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'rankpart_1_prt_extra'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'rankpart_1_prt_extra'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
300 | 0 | 10 | 0 | 300 | 0 | 300
@@ -498,7 +498,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'mt'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'mt'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
51 | 0 | 0 | 0 | 51 | 0 | 51
@@ -514,14 +514,14 @@ select pg_sleep(0.77) from gp_dist_random('gp_id'); -- Force pgstat_report_stat(
(3 rows)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'mt'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'mt'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
153 | 0 | 0 | 0 | 102 | 0 | 153
(1 row)
--- pg_stat_all_tables collects gpstats across segments
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'mt'::regclass;
+-- gp_stat_all_tables_summary collects gpstats across segments
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from gp_stat_all_tables_summary where relid = 'mt'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
153 | 0 | 0 | 0 | 102 | 0 | 153
@@ -539,7 +539,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'mt'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'mt'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
51 | 0 | 0 | 0 | 51 | 0 | 51
@@ -555,14 +555,14 @@ select pg_sleep(0.77) from gp_dist_random('gp_id'); -- Force pgstat_report_stat(
(3 rows)
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables_internal where relid = 'mt'::regclass;
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'mt'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
153 | 0 | 0 | 0 | 102 | 0 | 153
(1 row)
--- pg_stat_all_tables collects gpstats across segments
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'mt'::regclass;
+-- gp_stat_all_tables_summary collects gpstats across segments
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from gp_stat_all_tables_summary where relid = 'mt'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
153 | 0 | 0 | 0 | 102 | 0 | 153
@@ -580,7 +580,7 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select count(*) from pg_stat_all_tables
+select count(*) from gp_stat_all_tables_summary
where
relid = (select segrelid from pg_appendonly where relid = 'tabstat_ao'::regclass)
OR relid = (select blkdirrelid from pg_appendonly where relid = 'tabstat_ao'::regclass)
@@ -596,19 +596,19 @@ select pg_sleep(0.77); -- Force pgstat_report_stat() to send tabstat.
(1 row)
-select n_tup_ins from pg_stat_all_tables where relid = (select segrelid from pg_appendonly where relid = 'tabstat_ao'::regclass);
+select n_tup_ins from gp_stat_all_tables_summary where relid = (select segrelid from pg_appendonly where relid = 'tabstat_ao'::regclass);
n_tup_ins
-----------
1
(1 row)
-select n_tup_ins from pg_stat_all_tables where relid = (select blkdirrelid from pg_appendonly where relid = 'tabstat_ao'::regclass);
+select n_tup_ins from gp_stat_all_tables_summary where relid = (select blkdirrelid from pg_appendonly where relid = 'tabstat_ao'::regclass);
n_tup_ins
-----------
1
(1 row)
-select n_tup_ins from pg_stat_all_tables where relid = (select visimaprelid from pg_appendonly where relid = 'tabstat_ao'::regclass);
+select n_tup_ins from gp_stat_all_tables_summary where relid = (select visimaprelid from pg_appendonly where relid = 'tabstat_ao'::regclass);
n_tup_ins
-----------
1
diff --git a/contrib/pax_storage/src/test/regress/sql/pg_stat.sql b/contrib/pax_storage/src/test/regress/sql/pg_stat.sql
index d9fc37850b0..383a9149186 100644
--- a/contrib/pax_storage/src/test/regress/sql/pg_stat.sql
+++ b/contrib/pax_storage/src/test/regress/sql/pg_stat.sql
@@ -6,17 +6,17 @@ create table pg_stat_test(a int);
select
schemaname, relname, seq_scan, seq_tup_read, idx_scan, idx_tup_fetch, n_tup_ins, n_tup_upd,
n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup
-from pg_stat_all_tables where relname = 'pg_stat_test';
+from gp_stat_all_tables_summary where relname = 'pg_stat_test';
select
schemaname, relname, seq_scan, seq_tup_read, idx_scan, idx_tup_fetch, n_tup_ins, n_tup_upd,
n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup
-from pg_stat_user_tables where relname = 'pg_stat_test';
+from gp_stat_user_tables_summary where relname = 'pg_stat_test';
select
schemaname, relname, indexrelname, idx_scan, idx_tup_read, idx_tup_fetch
-from pg_stat_all_indexes where relname = 'pg_stat_test';
+from gp_stat_all_indexes_summary where relname = 'pg_stat_test';
select
schemaname, relname, indexrelname, idx_scan, idx_tup_read, idx_tup_fetch
-from pg_stat_user_indexes where relname = 'pg_stat_test';
+from gp_stat_user_indexes_summary where relname = 'pg_stat_test';
begin; -- make analyze same transcation with insert to avoid double the pgstat causes by unorder message read.
insert into pg_stat_test select * from generate_series(1, 100);
@@ -42,17 +42,17 @@ reset enable_seqscan;
select
schemaname, relname, seq_scan, seq_tup_read, idx_scan, idx_tup_fetch, n_tup_ins, n_tup_upd,
n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze
-from pg_stat_all_tables where relname = 'pg_stat_test';
+from gp_stat_all_tables_summary where relname = 'pg_stat_test';
select
schemaname, relname, seq_scan, seq_tup_read, idx_scan, idx_tup_fetch, n_tup_ins, n_tup_upd,
n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze
-from pg_stat_user_tables where relname = 'pg_stat_test';
+from gp_stat_user_tables_summary where relname = 'pg_stat_test';
select
schemaname, relname, indexrelname, idx_scan, idx_tup_read, idx_tup_fetch
-from pg_stat_all_indexes where relname = 'pg_stat_test';
+from gp_stat_all_indexes_summary where relname = 'pg_stat_test';
select
schemaname, relname, indexrelname, idx_scan, idx_tup_read, idx_tup_fetch
-from pg_stat_user_indexes where relname = 'pg_stat_test';
+from gp_stat_user_indexes_summary where relname = 'pg_stat_test';
reset optimizer;
reset max_parallel_workers_per_gather;
diff --git a/contrib/pax_storage/src/test/regress/sql/stats.sql b/contrib/pax_storage/src/test/regress/sql/stats.sql
index 36878562f87..94944161be7 100644
--- a/contrib/pax_storage/src/test/regress/sql/stats.sql
+++ b/contrib/pax_storage/src/test/regress/sql/stats.sql
@@ -20,7 +20,7 @@ SELECT t.seq_scan, t.seq_tup_read, t.idx_scan, t.idx_tup_fetch,
(b.heap_blks_read + b.heap_blks_hit) AS heap_blks,
(b.idx_blks_read + b.idx_blks_hit) AS idx_blks,
pg_stat_get_snapshot_timestamp() as snap_ts
- FROM pg_catalog.pg_stat_user_tables AS t,
+ FROM pg_catalog.gp_stat_user_tables_summary AS t,
pg_catalog.pg_statio_user_tables AS b
WHERE t.relname='tenk2' AND b.relname='tenk2';
@@ -44,17 +44,17 @@ begin
-- check to see if seqscan has been sensed
SELECT (st.seq_scan >= pr.seq_scan + 1) INTO updated1
- FROM pg_stat_user_tables AS st, pg_class AS cl, prevstats AS pr
+ FROM gp_stat_user_tables_summary AS st, pg_class AS cl, prevstats AS pr
WHERE st.relname='tenk2' AND cl.relname='tenk2';
-- check to see if indexscan has been sensed
SELECT (st.idx_scan >= pr.idx_scan + 1) INTO updated2
- FROM pg_stat_user_tables AS st, pg_class AS cl, prevstats AS pr
+ FROM gp_stat_user_tables_summary AS st, pg_class AS cl, prevstats AS pr
WHERE st.relname='tenk2' AND cl.relname='tenk2';
-- check to see if all updates have been sensed
SELECT (n_tup_ins > 0) INTO updated3
- FROM pg_stat_user_tables WHERE relname='trunc_stats_test4';
+ FROM gp_stat_user_tables_summary WHERE relname='trunc_stats_test4';
-- We must also check explicitly that pg_stat_get_snapshot_timestamp has
-- advanced, because that comes from the global stats file which might
@@ -64,7 +64,7 @@ begin
-- check to see if idx_tup_fetch has been sensed
SELECT (st.idx_tup_fetch >= pr.idx_tup_fetch + 1) INTO updated5
- FROM pg_stat_user_tables AS st, pg_class AS cl, prevstats AS pr
+ FROM gp_stat_user_tables_summary AS st, pg_class AS cl, prevstats AS pr
WHERE st.relname='tenk2' AND cl.relname='tenk2';
exit when updated1 and updated2 and updated3 and updated4 and updated5;
@@ -167,14 +167,14 @@ SELECT wait_for_stats();
-- check effects
SELECT relname, n_tup_ins, n_tup_upd, n_tup_del, n_live_tup, n_dead_tup
- FROM pg_stat_user_tables
+ FROM gp_stat_user_tables_summary
WHERE relname like 'trunc_stats_test%' order by relname;
SELECT st.seq_scan >= pr.seq_scan + 1,
st.seq_tup_read >= pr.seq_tup_read + cl.reltuples,
st.idx_scan >= pr.idx_scan + 1,
st.idx_tup_fetch >= pr.idx_tup_fetch + 1
- FROM pg_stat_user_tables AS st, pg_class AS cl, prevstats AS pr
+ FROM gp_stat_user_tables_summary AS st, pg_class AS cl, prevstats AS pr
WHERE st.relname='tenk2' AND cl.relname='tenk2';
-- GPDB_13_MERGE_FIXME: Some statistics are handled by stat collector process on each segment but not sent to master.
diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql
index d4d00b67771..23a68ab22c6 100644
--- a/src/backend/catalog/system_views.sql
+++ b/src/backend/catalog/system_views.sql
@@ -427,8 +427,7 @@ CREATE VIEW pg_prepared_xacts AS
LEFT JOIN pg_database D ON P.dbid = D.oid;
CREATE VIEW pg_prepared_statements AS
- SELECT pg_catalog.gp_execution_segment() AS gp_segment_id, *
- FROM pg_prepared_statement() AS P;
+ SELECT * FROM pg_prepared_statement() AS P;
CREATE VIEW pg_seclabels AS
SELECT
@@ -652,8 +651,7 @@ REVOKE ALL ON pg_shmem_allocations FROM PUBLIC;
REVOKE EXECUTE ON FUNCTION pg_get_shmem_allocations() FROM PUBLIC;
CREATE VIEW pg_backend_memory_contexts AS
- SELECT pg_catalog.gp_execution_segment() AS gp_segment_id, *
- FROM pg_get_backend_memory_contexts();
+ SELECT * FROM pg_get_backend_memory_contexts();
REVOKE ALL ON pg_backend_memory_contexts FROM PUBLIC;
REVOKE EXECUTE ON FUNCTION pg_get_backend_memory_contexts() FROM PUBLIC;
@@ -722,7 +720,7 @@ CREATE VIEW pg_stat_sys_tables AS
-- since we don't have segments.
-- We create a new view for single node mode.
CREATE VIEW pg_stat_sys_tables_single_node AS
- SELECT * FROM pg_stat_all_tables_internal
+ SELECT * FROM pg_stat_all_tables
WHERE schemaname IN ('pg_catalog', 'information_schema') OR
schemaname ~ '^pg_toast';
@@ -957,15 +955,6 @@ CREATE VIEW pg_stat_replication AS
JOIN pg_stat_get_wal_senders() AS W ON (S.pid = W.pid)
LEFT JOIN pg_authid AS U ON (S.usesysid = U.oid);
--- FIXME: remove it after 0d0fdc75ae5b72d42be549e234a29546efe07ca2
-CREATE VIEW gp_stat_activity AS
- SELECT gp_execution_segment() as gp_segment_id, * FROM gp_dist_random('pg_stat_activity')
- UNION ALL SELECT -1 as gp_segment_id, * from pg_stat_activity;
-
-CREATE VIEW gp_settings AS
- SELECT gp_execution_segment() as gp_segment_id, * FROM gp_dist_random('pg_settings')
- UNION ALL SELECT -1 as gp_segment_id, * from pg_settings;
-
CREATE FUNCTION gp_stat_get_master_replication() RETURNS SETOF RECORD AS
$$
SELECT pg_catalog.gp_execution_segment() AS gp_segment_id, *
@@ -1117,7 +1106,6 @@ CREATE VIEW pg_replication_slots AS
CREATE VIEW pg_stat_replication_slots AS
SELECT
- pg_catalog.gp_execution_segment() AS gp_segment_id,
s.slot_name,
s.spill_txns,
s.spill_count,
@@ -1134,7 +1122,6 @@ CREATE VIEW pg_stat_replication_slots AS
CREATE VIEW pg_stat_database AS
SELECT
- pg_catalog.gp_execution_segment() AS gp_segment_id,
D.oid AS datid,
D.datname AS datname,
CASE
@@ -1175,7 +1162,6 @@ CREATE VIEW pg_stat_database AS
CREATE VIEW pg_stat_resqueues AS
SELECT
- pg_catalog.gp_execution_segment() AS gp_segment_id,
Q.oid AS queueid,
Q.rsqname AS queuename,
pg_stat_get_queue_num_exec(Q.oid) AS n_queries_exec,
@@ -1475,9 +1461,8 @@ CREATE VIEW pg_stat_bgwriter AS
CREATE VIEW pg_stat_wal AS
SELECT
- pg_catalog.gp_execution_segment() AS gp_segment_id,
w.wal_records,
- w.wal_fpi,
+ w.wal_fpi as wal_fpw,
w.wal_bytes,
w.wal_buffers_full,
w.wal_write,
@@ -1489,7 +1474,6 @@ CREATE VIEW pg_stat_wal AS
CREATE VIEW pg_stat_progress_analyze AS
SELECT
- pg_catalog.gp_execution_segment() AS gp_segment_id,
S.pid AS pid, S.datid AS datid, D.datname AS datname,
CAST(S.relid AS oid) AS relid,
CASE S.param1 WHEN 0 THEN 'initializing'
@@ -1511,7 +1495,6 @@ CREATE VIEW pg_stat_progress_analyze AS
CREATE VIEW pg_stat_progress_vacuum AS
SELECT
- pg_catalog.gp_execution_segment() AS gp_segment_id,
S.pid AS pid, S.datid AS datid, D.datname AS datname,
S.relid AS relid,
CASE S.param1 WHEN 0 THEN 'initializing'
@@ -1533,7 +1516,6 @@ CREATE VIEW pg_stat_progress_vacuum AS
CREATE VIEW pg_stat_progress_cluster AS
SELECT
- pg_catalog.gp_execution_segment() AS gp_segment_id,
S.pid AS pid,
S.datid AS datid,
D.datname AS datname,
@@ -1561,7 +1543,6 @@ CREATE VIEW pg_stat_progress_cluster AS
CREATE VIEW pg_stat_progress_create_index AS
SELECT
- pg_catalog.gp_execution_segment() AS gp_segment_id,
S.pid AS pid, S.datid AS datid, D.datname AS datname,
S.relid AS relid,
CAST(S.param7 AS oid) AS index_relid,
@@ -1597,7 +1578,6 @@ CREATE VIEW pg_stat_progress_create_index AS
CREATE VIEW pg_stat_progress_basebackup AS
SELECT
- pg_catalog.gp_execution_segment() AS gp_segment_id,
S.pid AS pid,
CASE S.param1 WHEN 0 THEN 'initializing'
WHEN 1 THEN 'waiting for checkpoint to finish'
@@ -1615,7 +1595,6 @@ CREATE VIEW pg_stat_progress_basebackup AS
CREATE VIEW pg_stat_progress_copy AS
SELECT
- pg_catalog.gp_execution_segment() AS gp_segment_id,
S.pid AS pid, S.datid AS datid, D.datname AS datname,
S.relid AS relid,
CASE S.param5 WHEN 1 THEN 'COPY FROM'
diff --git a/src/backend/catalog/system_views_gp.in b/src/backend/catalog/system_views_gp.in
index cd865cea662..5f36752fc28 100644
--- a/src/backend/catalog/system_views_gp.in
+++ b/src/backend/catalog/system_views_gp.in
@@ -1,7 +1,7 @@
# This file lists all the PG system views 'pg_%' that we would like to create an
# MPP-aware view 'gp_%' out of. The generated 'gp_%' view definitions will be placed
# in system_views_gp.sql, and initialized at the same time as system_views.sql.
-#pg_backend_memory_contexts
+pg_backend_memory_contexts
pg_config
pg_cursors
pg_file_settings
@@ -13,16 +13,16 @@ pg_stat_all_indexes
pg_stat_all_tables
pg_stat_archiver
pg_stat_bgwriter
-#pg_stat_database
+pg_stat_database
pg_stat_database_conflicts
pg_stat_gssapi
pg_stat_operations
-#pg_stat_progress_analyze
-#pg_stat_progress_basebackup
-#pg_stat_progress_cluster
-#pg_stat_progress_copy
-#pg_stat_progress_create_index
-#pg_stat_progress_vacuum
+pg_stat_progress_analyze
+pg_stat_progress_basebackup
+pg_stat_progress_cluster
+pg_stat_progress_copy
+pg_stat_progress_create_index
+pg_stat_progress_vacuum
pg_stat_slru
pg_stat_ssl
pg_stat_subscription
@@ -31,7 +31,7 @@ pg_stat_sys_tables
pg_stat_user_functions
pg_stat_user_indexes
pg_stat_user_tables
-#pg_stat_wal
+pg_stat_wal
pg_stat_wal_receiver
pg_stat_xact_all_tables
pg_stat_xact_sys_tables
@@ -46,5 +46,5 @@ pg_statio_sys_tables
pg_statio_user_indexes
pg_statio_user_sequences
pg_statio_user_tables
-#pg_stats ERROR: column "most_common_vals" has pseudo-type anyarray
+pg_stats
pg_stats_ext
diff --git a/src/backend/catalog/system_views_gp_summary.sql b/src/backend/catalog/system_views_gp_summary.sql
index f83329203ab..6f42f7d4d80 100644
--- a/src/backend/catalog/system_views_gp_summary.sql
+++ b/src/backend/catalog/system_views_gp_summary.sql
@@ -135,6 +135,7 @@ FROM
case when d.policytype = 'r' then (sum(n_live_tup)/d.numsegments)::bigint else sum(n_live_tup) end n_live_tup,
case when d.policytype = 'r' then (sum(n_dead_tup)/d.numsegments)::bigint else sum(n_dead_tup) end n_dead_tup,
case when d.policytype = 'r' then (sum(n_mod_since_analyze)/d.numsegments)::bigint else sum(n_mod_since_analyze) end n_mod_since_analyze,
+ case when d.policytype = 'r' then (sum(n_ins_since_vacuum)/d.numsegments)::bigint else sum(n_ins_since_vacuum) end n_ins_since_vacuum,
max(last_vacuum) as last_vacuum,
max(last_autovacuum) as last_autovacuum,
max(last_analyze) as last_analyze,
diff --git a/src/test/isolation2/expected/analyze_progress.out b/src/test/isolation2/expected/analyze_progress.out
index 97c02fbe617..68faf24a5e8 100644
--- a/src/test/isolation2/expected/analyze_progress.out
+++ b/src/test/isolation2/expected/analyze_progress.out
@@ -92,4 +92,3 @@ ANALYZE
-- teardown
DROP TABLE t_analyze_repl;
DROP
-
diff --git a/src/test/isolation2/expected/ao_index_build_progress.out b/src/test/isolation2/expected/ao_index_build_progress.out
index 2cc97d09031..fd91bedfe58 100644
--- a/src/test/isolation2/expected/ao_index_build_progress.out
+++ b/src/test/isolation2/expected/ao_index_build_progress.out
@@ -142,7 +142,7 @@ SELECT gp_wait_until_triggered_fault('AppendOnlyStorageRead_ReadNextBlock_succes
-- By now, we should have reported some blocks (of size 'block_size') as "done",
-- as well as a total number of blocks that matches the size of col j's segfile.
-- Note: since we already had a block directory prior to the index build on
--- column 'j', only column 'j' will be scanned.
+-- column 'j', only column 'j' will be scanned. CBDB_CHERRY_PICK_MERGE_FIXME: fix when ao blkdir will be supported
1U: SELECT command, phase, ((pg_stat_file(pg_relation_filepath('aoco_index_build_progress') || '.' || 129)).size + (current_setting('block_size')::int - 1)) / current_setting('block_size')::int AS col_j_blocks, blocks_total AS blocks_total_reported, blocks_done AS blocks_done_reported FROM gp_stat_progress_create_index WHERE gp_segment_id = 1 AND relid = 'aoco_index_build_progress'::regclass;
command | phase | col_j_blocks | blocks_total_reported | blocks_done_reported
--------------+--------------------------------+--------------+-----------------------+----------------------
@@ -152,7 +152,7 @@ SELECT gp_wait_until_triggered_fault('AppendOnlyStorageRead_ReadNextBlock_succes
SELECT command, phase, blocks_total, blocks_done FROM gp_stat_progress_create_index_summary WHERE relid = 'aoco_index_build_progress'::regclass;
command | phase | blocks_total | blocks_done
--------------+--------------------------------+--------------+-------------
- CREATE INDEX | building index: scanning table | 24 | 9
+ CREATE INDEX | building index: scanning table | 60 | 12
(1 row)
SELECT gp_inject_fault('AppendOnlyStorageRead_ReadNextBlock_success', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
diff --git a/src/test/isolation2/expected/vacuum_progress_column.out b/src/test/isolation2/expected/vacuum_progress_column.out
index 587bd35f7c8..2889f8a9256 100644
--- a/src/test/isolation2/expected/vacuum_progress_column.out
+++ b/src/test/isolation2/expected/vacuum_progress_column.out
@@ -45,18 +45,6 @@ ABORT
DELETE FROM vacuum_progress_ao_column where j % 2 = 0;
DELETE 50000
--- Lookup pg_class and collected stats view before VACUUM
-SELECT relpages, reltuples, relallvisible FROM pg_class where relname = 'vacuum_progress_ao_column';
- relpages | reltuples | relallvisible
-----------+-----------+---------------
- 0 | -1 | 0
-(1 row)
-SELECT n_live_tup, n_dead_tup, last_vacuum, vacuum_count FROM pg_stat_all_tables WHERE relname = 'vacuum_progress_ao_column';
- n_live_tup | n_dead_tup | last_vacuum | vacuum_count
-------------+------------+-------------+--------------
- 100000 | 200000 | | 0
-(1 row)
-
-- Perform VACUUM and observe the progress
-- Suspend execution at pre-cleanup phase after truncating both segfiles to their logical EOF.
@@ -168,7 +156,7 @@ SELECT relpages, reltuples, relallvisible FROM pg_class where relname = 'vacuum_
----------+-----------+---------------
37 | 50000 | 0
(1 row)
-SELECT n_live_tup, n_dead_tup, last_vacuum is not null as has_last_vacuum, vacuum_count FROM pg_stat_all_tables WHERE relname = 'vacuum_progress_ao_column';
+SELECT n_live_tup, n_dead_tup, last_vacuum is not null as has_last_vacuum, vacuum_count FROM gp_stat_all_tables WHERE relname = 'vacuum_progress_ao_column' and gp_segment_id = 1;
n_live_tup | n_dead_tup | has_last_vacuum | vacuum_count
------------+------------+-----------------+--------------
50000 | 0 | t | 1
@@ -248,7 +236,7 @@ SELECT relpages, reltuples, relallvisible FROM pg_class where relname = 'vacuum_
----------+-----------+---------------
13 | 50000 | 0
(1 row)
-SELECT n_live_tup, n_dead_tup, last_vacuum is not null as has_last_vacuum, vacuum_count FROM pg_stat_all_tables WHERE relname = 'vacuum_progress_ao_column';
+SELECT n_live_tup, n_dead_tup, last_vacuum is not null as has_last_vacuum, vacuum_count FROM gp_stat_all_tables WHERE relname = 'vacuum_progress_ao_column' and gp_segment_id = 1;
n_live_tup | n_dead_tup | has_last_vacuum | vacuum_count
------------+------------+-----------------+--------------
50000 | 0 | t | 2
@@ -259,19 +247,6 @@ SELECT n_live_tup, n_dead_tup, last_vacuum is not null as has_last_vacuum, vacuu
-- Current behavior is it will clear previous compact phase num_dead_tuples in post-cleanup
-- phase (at injecting point vacuum_ao_post_cleanup_end), which is different from above case
-- in which vacuum worker isn't changed.
-ALTER SYSTEM SET gp_fts_mark_mirror_down_grace_period to 10;
-ALTER
-ALTER SYSTEM SET gp_fts_probe_interval to 10;
-ALTER
-SELECT gp_segment_id, pg_reload_conf() FROM gp_id UNION SELECT gp_segment_id, pg_reload_conf() FROM gp_dist_random('gp_id');
- gp_segment_id | pg_reload_conf
----------------+----------------
- 2 | t
- 1 | t
- 0 | t
- -1 | t
-(4 rows)
-
DROP TABLE IF EXISTS vacuum_progress_ao_column;
DROP
CREATE TABLE vacuum_progress_ao_column(i int, j int);
@@ -315,7 +290,7 @@ DELETE 50000
SET
1&: vacuum vacuum_progress_ao_column; <waiting ...>
-2: SELECT gp_wait_until_triggered_fault('vacuum_ao_after_compact', 3, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+2: SELECT gp_wait_until_triggered_fault('vacuum_ao_after_compact', 1, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
gp_wait_until_triggered_fault
-------------------------------
Success:
@@ -325,13 +300,17 @@ SET
-- Non-zero progressing data num_dead_tuples is showed up.
select gp_segment_id, relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id > -1;
-ERROR: relation "gp_stat_progress_vacuum" does not exist
-LINE 1: ...cuum_count, max_dead_tuples, num_dead_tuples from gp_stat_pr...
- ^
+ gp_segment_id | relname | phase | heap_blks_total | heap_blks_scanned | heap_blks_vacuumed | index_vacuum_count | max_dead_tuples | num_dead_tuples
+---------------+---------------------------+--------------------------+-----------------+-------------------+--------------------+--------------------+-----------------+-----------------
+ 1 | vacuum_progress_ao_column | append-optimized compact | 25 | 9 | 17 | 0 | 33327 | 16621
+ 0 | vacuum_progress_ao_column | append-optimized compact | 25 | 9 | 17 | 0 | 33462 | 16726
+ 2 | vacuum_progress_ao_column | append-optimized compact | 25 | 9 | 17 | 0 | 33211 | 16653
+(3 rows)
select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum_summary;
-ERROR: relation "gp_stat_progress_vacuum_summary" does not exist
-LINE 1: ...cuum_count, max_dead_tuples, num_dead_tuples from gp_stat_pr...
- ^
+ relname | phase | heap_blks_total | heap_blks_scanned | heap_blks_vacuumed | index_vacuum_count | max_dead_tuples | num_dead_tuples
+---------------------------+--------------------------+-----------------+-------------------+--------------------+--------------------+-----------------+-----------------
+ vacuum_progress_ao_column | append-optimized compact | 75 | 27 | 51 | 0 | 100000 | 50000
+(1 row)
-- Resume execution of compact phase and block at syncrep on one segment.
2: SELECT gp_inject_fault_infinite('wal_sender_loop', 'suspend', dbid) FROM gp_segment_configuration WHERE role = 'p' and content = 1;
@@ -372,7 +351,7 @@ LINE 1: ...cuum_count, max_dead_tuples, num_dead_tuples from gp_stat_pr...
-- initializes a new vacrelstats at the beginning of post-cleanup phase.
-- Also all segments should reach to the same "vacuum_worker_changed" point
-- due to FTS version being changed.
-2: SELECT gp_wait_until_triggered_fault('vacuum_worker_changed', 3, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+2: SELECT gp_wait_until_triggered_fault('vacuum_worker_changed', 1, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
gp_wait_until_triggered_fault
-------------------------------
Success:
@@ -383,10 +362,10 @@ LINE 1: ...cuum_count, max_dead_tuples, num_dead_tuples from gp_stat_pr...
2: SELECT content, role, preferred_role, mode, status FROM gp_segment_configuration WHERE content > -1;
content | role | preferred_role | mode | status
---------+------+----------------+------+--------
- 0 | p | p | s | u
- 0 | m | m | s | u
2 | p | p | s | u
2 | m | m | s | u
+ 0 | p | p | s | u
+ 0 | m | m | s | u
1 | p | p | n | u
1 | m | m | n | d
(6 rows)
@@ -406,7 +385,7 @@ LINE 1: ...cuum_count, max_dead_tuples, num_dead_tuples from gp_stat_pr...
Success:
Success:
(3 rows)
-2: SELECT gp_wait_until_triggered_fault('vacuum_ao_post_cleanup_end', 3, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+2: SELECT gp_wait_until_triggered_fault('vacuum_ao_post_cleanup_end', 1, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
gp_wait_until_triggered_fault
-------------------------------
Success:
@@ -416,13 +395,17 @@ LINE 1: ...cuum_count, max_dead_tuples, num_dead_tuples from gp_stat_pr...
-- The previous collected num_dead_tuples in compact phase is zero.
select gp_segment_id, relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id > -1;
-ERROR: relation "gp_stat_progress_vacuum" does not exist
-LINE 1: ...cuum_count, max_dead_tuples, num_dead_tuples from gp_stat_pr...
- ^
+ gp_segment_id | relname | phase | heap_blks_total | heap_blks_scanned | heap_blks_vacuumed | index_vacuum_count | max_dead_tuples | num_dead_tuples
+---------------+---------------------------+-------------------------------+-----------------+-------------------+--------------------+--------------------+-----------------+-----------------
+ 2 | vacuum_progress_ao_column | append-optimized post-cleanup | 0 | 0 | 0 | 0 | 0 | 0
+ 0 | vacuum_progress_ao_column | append-optimized post-cleanup | 0 | 0 | 0 | 0 | 0 | 0
+ 1 | vacuum_progress_ao_column | append-optimized post-cleanup | 0 | 0 | 0 | 0 | 0 | 0
+(3 rows)
select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum_summary;
-ERROR: relation "gp_stat_progress_vacuum_summary" does not exist
-LINE 1: ...cuum_count, max_dead_tuples, num_dead_tuples from gp_stat_pr...
- ^
+ relname | phase | heap_blks_total | heap_blks_scanned | heap_blks_vacuumed | index_vacuum_count | max_dead_tuples | num_dead_tuples
+---------------------------+-------------------------------+-----------------+-------------------+--------------------+--------------------+-----------------+-----------------
+ vacuum_progress_ao_column | append-optimized post-cleanup | 0 | 0 | 0 | 0 | 0 | 0
+(1 row)
2: SELECT gp_inject_fault('vacuum_ao_post_cleanup_end', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
gp_inject_fault
@@ -469,15 +452,3 @@ reset Debug_appendonly_print_compaction;
RESET
reset default_table_access_method;
RESET
-ALTER SYSTEM RESET gp_fts_mark_mirror_down_grace_period;
-ALTER
-ALTER SYSTEM RESET gp_fts_probe_interval;
-ALTER
-SELECT gp_segment_id, pg_reload_conf() FROM gp_id UNION SELECT gp_segment_id, pg_reload_conf() FROM gp_dist_random('gp_id');
- gp_segment_id | pg_reload_conf
----------------+----------------
- 2 | t
- 1 | t
- 0 | t
- -1 | t
-(4 rows)
diff --git a/src/test/isolation2/expected/vacuum_progress_row.out b/src/test/isolation2/expected/vacuum_progress_row.out
index 619b3e41b80..81392c5a9ef 100644
--- a/src/test/isolation2/expected/vacuum_progress_row.out
+++ b/src/test/isolation2/expected/vacuum_progress_row.out
@@ -44,23 +44,6 @@ ABORT
DELETE FROM vacuum_progress_ao_row where j % 2 = 0;
DELETE 50000
--- Lookup pg_class and collected stats view before VACUUM
-SELECT relpages, reltuples, relallvisible FROM pg_class where relname = 'vacuum_progress_ao_row';
- relpages | reltuples | relallvisible
-----------+-----------+---------------
- 0 | -1 | 0
-(1 row)
-SELECT n_live_tup, n_dead_tup, last_vacuum, vacuum_count FROM pg_stat_all_tables WHERE relname = 'vacuum_progress_ao_row';
- n_live_tup | n_dead_tup | last_vacuum | vacuum_count
-------------+------------+-------------+--------------
- 33327 | 66654 | | 0
-(1 row)
-SELECT n_live_tup, n_dead_tup, last_vacuum, vacuum_count FROM gp_stat_all_tables_summary WHERE relname = 'vacuum_progress_ao_row';
- n_live_tup | n_dead_tup | last_vacuum | vacuum_count
-------------+------------+-------------+--------------
- 100000 | 200000 | | 0
-(1 row)
-
-- Perform VACUUM and observe the progress
-- Suspend execution at pre-cleanup phase after truncating both segfiles to their logical EOF.
@@ -139,11 +122,13 @@ SELECT gp_inject_fault('appendonly_insert', 'reset', dbid) FROM gp_segment_confi
Success:
Success:
(3 rows)
-SELECT gp_wait_until_triggered_fault('vacuum_ao_after_compact', 1, dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+SELECT gp_wait_until_triggered_fault('vacuum_ao_after_compact', 1, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
gp_wait_until_triggered_fault
-------------------------------
Success:
-(1 row)
+ Success:
+ Success:
+(3 rows)
-- After compacting all segfiles we expect 50000 dead tuples
select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id = 1;
relname | phase | heap_blks_total | heap_blks_scanned | heap_blks_vacuumed | index_vacuum_count | max_dead_tuples | num_dead_tuples
@@ -171,11 +156,13 @@ SELECT gp_inject_fault('vacuum_ao_after_compact', 'reset', dbid) FROM gp_segment
Success:
Success:
(3 rows)
-SELECT gp_wait_until_triggered_fault('vacuum_ao_post_cleanup_end', 1, dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+SELECT gp_wait_until_triggered_fault('vacuum_ao_post_cleanup_end', 1, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
gp_wait_until_triggered_fault
-------------------------------
Success:
-(1 row)
+ Success:
+ Success:
+(3 rows)
-- We should have skipped recycling the awaiting drop segment because the segment was still visible to the SELECT gp_wait_until_triggered_fault query.
select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id = 1;
relname | phase | heap_blks_total | heap_blks_scanned | heap_blks_vacuumed | index_vacuum_count | max_dead_tuples | num_dead_tuples
@@ -209,7 +196,7 @@ SELECT relpages, reltuples, relallvisible FROM pg_class where relname = 'vacuum_
----------+-----------+---------------
84 | 50000 | 0
(1 row)
-SELECT n_live_tup, n_dead_tup, last_vacuum is not null as has_last_vacuum, vacuum_count FROM pg_stat_all_tables WHERE relname = 'vacuum_progress_ao_row';
+SELECT n_live_tup, n_dead_tup, last_vacuum is not null as has_last_vacuum, vacuum_count FROM gp_stat_all_tables WHERE relname = 'vacuum_progress_ao_row' and gp_segment_id = 1;
n_live_tup | n_dead_tup | has_last_vacuum | vacuum_count
------------+------------+-----------------+--------------
16705 | 0 | t | 1
@@ -297,7 +284,7 @@ SELECT relpages, reltuples, relallvisible FROM pg_class where relname = 'vacuum_
----------+-----------+---------------
30 | 50000 | 0
(1 row)
-SELECT n_live_tup, n_dead_tup, last_vacuum is not null as has_last_vacuum, vacuum_count FROM pg_stat_all_tables WHERE relname = 'vacuum_progress_ao_row';
+SELECT n_live_tup, n_dead_tup, last_vacuum is not null as has_last_vacuum, vacuum_count FROM gp_stat_all_tables WHERE relname = 'vacuum_progress_ao_row' and gp_segment_id = 1;
n_live_tup | n_dead_tup | has_last_vacuum | vacuum_count
------------+------------+-----------------+--------------
16705 | 0 | t | 2
@@ -308,87 +295,213 @@ SELECT n_live_tup, n_dead_tup, last_vacuum is not null as has_last_vacuum, vacuu
50000 | 0 | t | 2
(1 row)
--- open if system views gp_stat_progress_vacuum* are enabled
---1q:
----- Test vacuum worker process is changed at post-cleanup phase due to mirror down.
----- Current behavior is it will clear previous compact phase num_dead_tuples in post-cleanup
----- phase (at injecting point vacuum_ao_post_cleanup_end), which is different from above case
----- in which vacuum worker isn't changed.
---ALTER SYSTEM SET gp_fts_mark_mirror_down_grace_period to 10;
---ALTER SYSTEM SET gp_fts_probe_interval to 10;
---SELECT gp_segment_id, pg_reload_conf() FROM gp_id UNION SELECT gp_segment_id, pg_reload_conf() FROM gp_dist_random('gp_id');
---
---DROP TABLE IF EXISTS vacuum_progress_ao_row;
---CREATE TABLE vacuum_progress_ao_row(i int, j int);
---CREATE INDEX on vacuum_progress_ao_row(i);
---CREATE INDEX on vacuum_progress_ao_row(j);
---1: BEGIN;
---2: BEGIN;
---1: INSERT INTO vacuum_progress_ao_row SELECT i, i FROM generate_series(1, 100000) i;
---2: INSERT INTO vacuum_progress_ao_row SELECT i, i FROM generate_series(1, 100000) i;
---2: COMMIT;
---2: BEGIN;
---2: INSERT INTO vacuum_progress_ao_row SELECT i, i FROM generate_series(1, 100000) i;
---2: ABORT;
---2q:
---1: ABORT;
---DELETE FROM vacuum_progress_ao_row where j % 2 = 0;
---
----- Suspend execution at the end of compact phase.
---2: SELECT gp_inject_fault('vacuum_ao_after_compact', 'suspend', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
---
---1: set debug_appendonly_print_compaction to on;
---1&: vacuum vacuum_progress_ao_row;
---
---2: SELECT gp_wait_until_triggered_fault('vacuum_ao_after_compact', 3, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
---
----- Non-zero progressing data num_dead_tuples is showed up.
---select gp_segment_id, relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id > -1;
---select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum_summary;
---
----- Resume execution of compact phase and block at syncrep.
---2: SELECT gp_inject_fault_infinite('wal_sender_loop', 'suspend', dbid) FROM gp_segment_configuration WHERE role = 'p' and content = 1;
---2: SELECT gp_inject_fault('vacuum_ao_after_compact', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
----- stop the mirror should turn off syncrep
---2: SELECT pg_ctl(datadir, 'stop', 'immediate') FROM gp_segment_configuration WHERE content=1 AND role = 'm';
---
----- Resume walsender to detect mirror down and suspend at the beginning
----- of post-cleanup taken over by a new vacuum worker.
---2: SELECT gp_inject_fault('vacuum_worker_changed', 'suspend', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
----- resume walsender and let it exit so that mirror stop can be detected
---2: SELECT gp_inject_fault_infinite('wal_sender_loop', 'reset', dbid) FROM gp_segment_configuration WHERE role = 'p' and content = 1;
----- Ensure we enter into the target logic which stops cumulative data but
----- initializes a new vacrelstats at the beginning of post-cleanup phase.
----- Also all segments should reach to the same "vacuum_worker_changed" point
----- due to FTS version being changed.
---2: SELECT gp_wait_until_triggered_fault('vacuum_worker_changed', 1, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
----- now seg1's mirror is marked as down
---2: SELECT content, role, preferred_role, mode, status FROM gp_segment_configuration WHERE content > -1;
---
----- Resume execution and entering post_cleaup phase, suspend at the end of it.
---2: SELECT gp_inject_fault('vacuum_ao_post_cleanup_end', 'suspend', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
---2: SELECT gp_inject_fault('vacuum_worker_changed', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
---2: SELECT gp_wait_until_triggered_fault('vacuum_ao_post_cleanup_end', 1, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
---
----- The previous collected num_dead_tuples in compact phase is zero.
---select gp_segment_id, relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id > -1;
---select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum_summary;
---
---2: SELECT gp_inject_fault('vacuum_ao_post_cleanup_end', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
---
---1<:
---
----- restore environment
---1: reset debug_appendonly_print_compaction;
---
---2: SELECT pg_ctl_start(datadir, port) FROM gp_segment_configuration WHERE role = 'm' AND content = 1;
---2: SELECT wait_until_all_segments_synchronized();
---
----- Cleanup
---SELECT gp_inject_fault_infinite('all', 'reset', dbid) FROM gp_segment_configuration;
---reset Debug_appendonly_print_compaction;
---reset default_table_access_method;
---ALTER SYSTEM RESET gp_fts_mark_mirror_down_grace_period;
---ALTER SYSTEM RESET gp_fts_probe_interval;
---SELECT gp_segment_id, pg_reload_conf() FROM gp_id UNION SELECT gp_segment_id, pg_reload_conf() FROM gp_dist_random('gp_id');
---
+1q: ... <quitting>
+-- Test vacuum worker process is changed at post-cleanup phase due to mirror down.
+-- Current behavior is it will clear previous compact phase num_dead_tuples in post-cleanup
+-- phase (at injecting point vacuum_ao_post_cleanup_end), which is different from above case
+-- in which vacuum worker isn't changed.
+DROP TABLE IF EXISTS vacuum_progress_ao_row;
+DROP
+CREATE TABLE vacuum_progress_ao_row(i int, j int);
+CREATE
+CREATE INDEX on vacuum_progress_ao_row(i);
+CREATE
+CREATE INDEX on vacuum_progress_ao_row(j);
+CREATE
+1: BEGIN;
+BEGIN
+2: BEGIN;
+BEGIN
+1: INSERT INTO vacuum_progress_ao_row SELECT i, i FROM generate_series(1, 100000) i;
+INSERT 100000
+2: INSERT INTO vacuum_progress_ao_row SELECT i, i FROM generate_series(1, 100000) i;
+INSERT 100000
+2: COMMIT;
+COMMIT
+2: BEGIN;
+BEGIN
+2: INSERT INTO vacuum_progress_ao_row SELECT i, i FROM generate_series(1, 100000) i;
+INSERT 100000
+2: ABORT;
+ABORT
+2q: ... <quitting>
+1: ABORT;
+ABORT
+DELETE FROM vacuum_progress_ao_row where j % 2 = 0;
+DELETE 50000
+
+-- Suspend execution at the end of compact phase.
+2: SELECT gp_inject_fault('vacuum_ao_after_compact', 'suspend', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+ gp_inject_fault
+-----------------
+ Success:
+ Success:
+ Success:
+(3 rows)
+
+1: set debug_appendonly_print_compaction to on;
+SET
+1&: vacuum vacuum_progress_ao_row; <waiting ...>
+
+2: SELECT gp_wait_until_triggered_fault('vacuum_ao_after_compact', 1, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+ gp_wait_until_triggered_fault
+-------------------------------
+ Success:
+ Success:
+ Success:
+(3 rows)
+
+-- Non-zero progressing data num_dead_tuples is showed up.
+select gp_segment_id, relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id > -1;
+ gp_segment_id | relname | phase | heap_blks_total | heap_blks_scanned | heap_blks_vacuumed | index_vacuum_count | max_dead_tuples | num_dead_tuples
+---------------+------------------------+--------------------------+-----------------+-------------------+--------------------+--------------------+-----------------+-----------------
+ 1 | vacuum_progress_ao_row | append-optimized compact | 55 | 19 | 37 | 0 | 33327 | 16622
+ 2 | vacuum_progress_ao_row | append-optimized compact | 55 | 19 | 37 | 0 | 33211 | 16653
+ 0 | vacuum_progress_ao_row | append-optimized compact | 56 | 19 | 37 | 0 | 33462 | 16725
+(3 rows)
+select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum_summary;
+ relname | phase | heap_blks_total | heap_blks_scanned | heap_blks_vacuumed | index_vacuum_count | max_dead_tuples | num_dead_tuples
+------------------------+--------------------------+-----------------+-------------------+--------------------+--------------------+-----------------+-----------------
+ vacuum_progress_ao_row | append-optimized compact | 166 | 57 | 111 | 0 | 100000 | 50000
+(1 row)
+
+-- Resume execution of compact phase and block at syncrep.
+2: SELECT gp_inject_fault_infinite('wal_sender_loop', 'suspend', dbid) FROM gp_segment_configuration WHERE role = 'p' and content = 1;
+ gp_inject_fault_infinite
+--------------------------
+ Success:
+(1 row)
+2: SELECT gp_inject_fault('vacuum_ao_after_compact', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+ gp_inject_fault
+-----------------
+ Success:
+ Success:
+ Success:
+(3 rows)
+-- stop the mirror should turn off syncrep
+2: SELECT pg_ctl(datadir, 'stop', 'immediate') FROM gp_segment_configuration WHERE content=1 AND role = 'm';
+ pg_ctl
+--------
+ OK
+(1 row)
+
+-- Resume walsender to detect mirror down and suspend at the beginning
+-- of post-cleanup taken over by a new vacuum worker.
+2: SELECT gp_inject_fault('vacuum_worker_changed', 'suspend', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+ gp_inject_fault
+-----------------
+ Success:
+ Success:
+ Success:
+(3 rows)
+-- resume walsender and let it exit so that mirror stop can be detected
+2: SELECT gp_inject_fault_infinite('wal_sender_loop', 'reset', dbid) FROM gp_segment_configuration WHERE role = 'p' and content = 1;
+ gp_inject_fault_infinite
+--------------------------
+ Success:
+(1 row)
+-- Ensure we enter into the target logic which stops cumulative data but
+-- initializes a new vacrelstats at the beginning of post-cleanup phase.
+-- Also all segments should reach to the same "vacuum_worker_changed" point
+-- due to FTS version being changed.
+2: SELECT gp_wait_until_triggered_fault('vacuum_worker_changed', 1, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+ gp_wait_until_triggered_fault
+-------------------------------
+ Success:
+ Success:
+ Success:
+(3 rows)
+-- now seg1's mirror is marked as down
+2: SELECT content, role, preferred_role, mode, status FROM gp_segment_configuration WHERE content > -1;
+ content | role | preferred_role | mode | status
+---------+------+----------------+------+--------
+ 2 | p | p | s | u
+ 2 | m | m | s | u
+ 0 | p | p | s | u
+ 0 | m | m | s | u
+ 1 | p | p | n | u
+ 1 | m | m | n | d
+(6 rows)
+
+-- Resume execution and entering post_cleaup phase, suspend at the end of it.
+2: SELECT gp_inject_fault('vacuum_ao_post_cleanup_end', 'suspend', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+ gp_inject_fault
+-----------------
+ Success:
+ Success:
+ Success:
+(3 rows)
+2: SELECT gp_inject_fault('vacuum_worker_changed', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+ gp_inject_fault
+-----------------
+ Success:
+ Success:
+ Success:
+(3 rows)
+2: SELECT gp_wait_until_triggered_fault('vacuum_ao_post_cleanup_end', 1, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+ gp_wait_until_triggered_fault
+-------------------------------
+ Success:
+ Success:
+ Success:
+(3 rows)
+
+-- The previous collected num_dead_tuples in compact phase is zero.
+select gp_segment_id, relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id > -1;
+ gp_segment_id | relname | phase | heap_blks_total | heap_blks_scanned | heap_blks_vacuumed | index_vacuum_count | max_dead_tuples | num_dead_tuples
+---------------+------------------------+-------------------------------+-----------------+-------------------+--------------------+--------------------+-----------------+-----------------
+ 0 | vacuum_progress_ao_row | append-optimized post-cleanup | 0 | 0 | 0 | 0 | 0 | 0
+ 2 | vacuum_progress_ao_row | append-optimized post-cleanup | 0 | 0 | 0 | 0 | 0 | 0
+ 1 | vacuum_progress_ao_row | append-optimized post-cleanup | 0 | 0 | 0 | 0 | 0 | 0
+(3 rows)
+select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum_summary;
+ relname | phase | heap_blks_total | heap_blks_scanned | heap_blks_vacuumed | index_vacuum_count | max_dead_tuples | num_dead_tuples
+------------------------+-------------------------------+-----------------+-------------------+--------------------+--------------------+-----------------+-----------------
+ vacuum_progress_ao_row | append-optimized post-cleanup | 0 | 0 | 0 | 0 | 0 | 0
+(1 row)
+
+2: SELECT gp_inject_fault('vacuum_ao_post_cleanup_end', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+ gp_inject_fault
+-----------------
+ Success:
+ Success:
+ Success:
+(3 rows)
+
+1<: <... completed>
+VACUUM
+
+-- restore environment
+1: reset debug_appendonly_print_compaction;
+RESET
+
+2: SELECT pg_ctl_start(datadir, port) FROM gp_segment_configuration WHERE role = 'm' AND content = 1;
+ pg_ctl_start
+--------------------------------------------------
+ waiting for server to start done
+server started
+
+(1 row)
+2: SELECT wait_until_all_segments_synchronized();
+ wait_until_all_segments_synchronized
+--------------------------------------
+ OK
+(1 row)
+
+-- Cleanup
+SELECT gp_inject_fault_infinite('all', 'reset', dbid) FROM gp_segment_configuration;
+ gp_inject_fault_infinite
+--------------------------
+ Success:
+ Success:
+ Success:
+ Success:
+ Success:
+ Success:
+ Success:
+ Success:
+(8 rows)
+reset Debug_appendonly_print_compaction;
+RESET
+reset default_table_access_method;
+RESET
diff --git a/src/test/isolation2/input/autovacuum-analyze.source b/src/test/isolation2/input/autovacuum-analyze.source
index 32e79cdd491..19187b107c2 100644
--- a/src/test/isolation2/input/autovacuum-analyze.source
+++ b/src/test/isolation2/input/autovacuum-analyze.source
@@ -178,7 +178,7 @@ SELECT count(*) FROM pg_statistic where starelid = 'autostatstbl'::regclass;
select relpages, reltuples from pg_class where oid = 'autostatstbl'::regclass;
-- expect analyze_count = 1, autoanalyze_count = 0, and n_mod_since_analyze = 1000 since ANALYZE executed
-- in same transaction for the insert statement.
-select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables_internal where relname = 'autostatstbl';
+select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables where relname = 'autostatstbl';
-- Wait until autovacuum is triggered
SELECT gp_wait_until_triggered_fault('auto_vac_worker_after_report_activity', 1, 1);
@@ -192,7 +192,7 @@ SELECT gp_inject_fault('analyze_finished_one_relation', 'reset', 1);
-- we can see the auto-ANALYZE finished
select relpages, reltuples from pg_class where oid = 'autostatstbl'::regclass;
-- expect analyze_count = 1, autoanalyze_count = 1, and n_mod_since_analyze = 0
-select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables_internal where relname = 'autostatstbl';
+select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables where relname = 'autostatstbl';
-- Case 2 --
-- with auto_stats 'on_change' mode, the auto-ANALYZE still trigger
@@ -211,7 +211,7 @@ SELECT gp_inject_fault('auto_vac_worker_after_report_activity', 'suspend', '', '
select relpages, reltuples from pg_class where oid = 'autostatstbl'::regclass;
-- expect analyze_count = 2, autoanalyze_count = 1, and n_mod_since_analyze = 1000 since ANALYZE executed
-- in same transaction for the insert statement.
-select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables_internal where relname = 'autostatstbl';
+select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables where relname = 'autostatstbl';
-- Wait until autovacuum is triggered
SELECT gp_wait_until_triggered_fault('auto_vac_worker_after_report_activity', 1, 1);
@@ -225,7 +225,7 @@ SELECT gp_inject_fault('analyze_finished_one_relation', 'reset', 1);
-- we can see the auto-ANALYZE finished, check statistic and analyze count
select relpages, reltuples from pg_class where oid = 'autostatstbl'::regclass;
-- expect analyze_count = 2, autoanalyze_count = 2, and n_mod_since_analyze = 0
-select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables_internal where relname = 'autostatstbl';
+select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables where relname = 'autostatstbl';
-- Case 3 --
@@ -244,7 +244,7 @@ SELECT gp_inject_fault('auto_vac_worker_after_report_activity', 'suspend', '', '
select relpages, reltuples from pg_class where oid = 'autostatstbl'::regclass;
-- expect analyze_count = 2, autoanalyze_count = 2, and n_mod_since_analyze = 1000 since ANALYZE executed
-- in same transaction for the insert statement.
-select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables_internal where relname = 'autostatstbl';
+select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables where relname = 'autostatstbl';
-- Wait until autovacuum is triggered
SELECT gp_wait_until_triggered_fault('auto_vac_worker_after_report_activity', 1, 1);
@@ -258,7 +258,7 @@ SELECT gp_inject_fault('analyze_finished_one_relation', 'reset', 1);
-- we can see the auto-ANALYZE finished, check statistic and analyze count
select relpages, reltuples from pg_class where oid = 'autostatstbl'::regclass;
-- expect analyze_count = 2, autoanalyze_count = 3, and n_mod_since_analyze = 0 since ANALYZE executed
-select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables_internal where relname = 'autostatstbl';
+select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables where relname = 'autostatstbl';
-- Reset GUCs.
ALTER SYSTEM RESET autovacuum_naptime;
diff --git a/src/test/isolation2/output/autovacuum-analyze.source b/src/test/isolation2/output/autovacuum-analyze.source
index e071f9e7007..b8727a10a51 100644
--- a/src/test/isolation2/output/autovacuum-analyze.source
+++ b/src/test/isolation2/output/autovacuum-analyze.source
@@ -422,7 +422,7 @@ select relpages, reltuples from pg_class where oid = 'autostatstbl'::regclass;
(1 row)
-- expect analyze_count = 1, autoanalyze_count = 0, and n_mod_since_analyze = 1000 since ANALYZE executed
-- in same transaction for the insert statement.
-select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables_internal where relname = 'autostatstbl';
+select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables where relname = 'autostatstbl';
analyze_count | autoanalyze_count | n_mod_since_analyze
---------------+-------------------+---------------------
1 | 0 | 1000
@@ -465,7 +465,7 @@ select relpages, reltuples from pg_class where oid = 'autostatstbl'::regclass;
3 | 1000
(1 row)
-- expect analyze_count = 1, autoanalyze_count = 1, and n_mod_since_analyze = 0
-select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables_internal where relname = 'autostatstbl';
+select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables where relname = 'autostatstbl';
analyze_count | autoanalyze_count | n_mod_since_analyze
---------------+-------------------+---------------------
1 | 1 | 0
@@ -502,7 +502,7 @@ select relpages, reltuples from pg_class where oid = 'autostatstbl'::regclass;
(1 row)
-- expect analyze_count = 2, autoanalyze_count = 1, and n_mod_since_analyze = 1000 since ANALYZE executed
-- in same transaction for the insert statement.
-select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables_internal where relname = 'autostatstbl';
+select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables where relname = 'autostatstbl';
analyze_count | autoanalyze_count | n_mod_since_analyze
---------------+-------------------+---------------------
2 | 1 | 1000
@@ -545,7 +545,7 @@ select relpages, reltuples from pg_class where oid = 'autostatstbl'::regclass;
3 | 2000
(1 row)
-- expect analyze_count = 2, autoanalyze_count = 2, and n_mod_since_analyze = 0
-select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables_internal where relname = 'autostatstbl';
+select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables where relname = 'autostatstbl';
analyze_count | autoanalyze_count | n_mod_since_analyze
---------------+-------------------+---------------------
2 | 2 | 0
@@ -581,7 +581,7 @@ select relpages, reltuples from pg_class where oid = 'autostatstbl'::regclass;
(1 row)
-- expect analyze_count = 2, autoanalyze_count = 2, and n_mod_since_analyze = 1000 since ANALYZE executed
-- in same transaction for the insert statement.
-select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables_internal where relname = 'autostatstbl';
+select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables where relname = 'autostatstbl';
analyze_count | autoanalyze_count | n_mod_since_analyze
---------------+-------------------+---------------------
2 | 2 | 1000
@@ -624,7 +624,7 @@ select relpages, reltuples from pg_class where oid = 'autostatstbl'::regclass;
6 | 3000
(1 row)
-- expect analyze_count = 2, autoanalyze_count = 3, and n_mod_since_analyze = 0 since ANALYZE executed
-select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables_internal where relname = 'autostatstbl';
+select analyze_count, autoanalyze_count, n_mod_since_analyze from pg_stat_all_tables where relname = 'autostatstbl';
analyze_count | autoanalyze_count | n_mod_since_analyze
---------------+-------------------+---------------------
2 | 3 | 0
diff --git a/src/test/isolation2/output/parallel_retrieve_cursor/explain.source b/src/test/isolation2/output/parallel_retrieve_cursor/explain.source
index e26fe7bd9fa..15baecb724f 100644
--- a/src/test/isolation2/output/parallel_retrieve_cursor/explain.source
+++ b/src/test/isolation2/output/parallel_retrieve_cursor/explain.source
@@ -129,14 +129,17 @@ EXPLAIN (VERBOSE, COSTS false) DECLARE c1 PARALLEL RETRIEVE CURSOR FOR SELECT *
Optimizer: Postgres query optimizer
(5 rows)
EXPLAIN (VERBOSE, COSTS false) DECLARE c1 PARALLEL RETRIEVE CURSOR FOR SELECT * FROM pg_class ORDER BY relname;
- QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- Index Scan using pg_class_relname_nsp_index on pg_catalog.pg_class
- Output: oid, relname, relnamespace, reltype, reloftype, relowner, relam, relfilenode, reltablespace, relpages, reltuples, relallvisible, reltoastrelid, relhasindex, relisshared, relpersistence, relkind, relnatts, relchecks, relhasrules, relhastriggers, relhassubclass, relrowsecurity, relforcerowsecurity, relispopulated, relreplident, relispartition, relisivm, relisdynamic, relmvrefcount, relrewrite, relfrozenxid, relminmxid, relacl, reloptions, relpartbound
- Settings: enable_incremental_sort = 'on'
- Endpoint: "on coordinator"
- Optimizer: Postgres query optimizer
-(5 rows)
+ QUERY PLAN
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ Sort
+ Output: oid, relname, relnamespace, reltype, reloftype, relowner, relam, relfilenode, reltablespace, relpages, reltuples, relallvisible, reltoastrelid, relhasindex, relisshared, relpersistence, relkind, relnatts, relchecks, relhasrules, relhastriggers, relhassubclass, relrowsecurity, relforcerowsecurity, relispopulated, relreplident, relispartition, relisivm, relisdynamic, relmvrefcount, relrewrite, relfrozenxid, relminmxid, relacl, reloptions, relpartbound
+ Sort Key: pg_class.relname
+ -> Seq Scan on pg_catalog.pg_class
+ Output: oid, relname, relnamespace, reltype, reloftype, relowner, relam, relfilenode, reltablespace, relpages, reltuples, relallvisible, reltoastrelid, relhasindex, relisshared, relpersistence, relkind, relnatts, relchecks, relhasrules, relhastriggers, relhassubclass, relrowsecurity, relforcerowsecurity, relispopulated, relreplident, relispartition, relisivm, relisdynamic, relmvrefcount, relrewrite, relfrozenxid, relminmxid, relacl, reloptions, relpartbound
+ Settings: enable_incremental_sort = 'on'
+ Endpoint: "on coordinator"
+ Optimizer: Postgres query optimizer
+(8 rows)
EXPLAIN (VERBOSE, COSTS false) DECLARE c1 PARALLEL RETRIEVE CURSOR FOR SELECT * FROM pg_class WHERE gp_segment_id=1;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
diff --git a/src/test/isolation2/sql/setup.sql b/src/test/isolation2/sql/setup.sql
index 6241413ba3b..949f22f0002 100644
--- a/src/test/isolation2/sql/setup.sql
+++ b/src/test/isolation2/sql/setup.sql
@@ -461,27 +461,6 @@ begin
end; /* in func */
$$ language plpgsql;
--- Helper function that ensures stats collector receives stat from the latest operation.
-create or replace function wait_until_vacuum_count_change_to(relid oid, stat_val_expected bigint)
- returns text as $$
-declare
- stat_val int; /* in func */
- i int; /* in func */
-begin
- i := 0; /* in func */
- while i < 1200 loop
- select pg_stat_get_vacuum_count(relid) into stat_val; /* in func */
- if stat_val = stat_val_expected then /* in func */
- return 'OK'; /* in func */
- end if; /* in func */
- perform pg_sleep(0.1); /* in func */
- perform pg_stat_clear_snapshot(); /* in func */
- i := i + 1; /* in func */
- end loop; /* in func */
- return 'Fail'; /* in func */
-end; /* in func */
-$$ language plpgsql;
-
-- Helper function to get the number of blocks in a relation.
CREATE OR REPLACE FUNCTION nblocks(rel regclass) RETURNS int AS $$ /* in func */
BEGIN /* in func */
diff --git a/src/test/isolation2/sql/vacuum_progress_column.sql b/src/test/isolation2/sql/vacuum_progress_column.sql
index 648d43303be..cff0d8394ba 100644
--- a/src/test/isolation2/sql/vacuum_progress_column.sql
+++ b/src/test/isolation2/sql/vacuum_progress_column.sql
@@ -30,10 +30,6 @@ CREATE INDEX on vacuum_progress_ao_column(j);
-- Also delete half of the tuples evenly before the EOF of segno 2.
DELETE FROM vacuum_progress_ao_column where j % 2 = 0;
--- Lookup pg_class and collected stats view before VACUUM
-SELECT relpages, reltuples, relallvisible FROM pg_class where relname = 'vacuum_progress_ao_column';
-SELECT n_live_tup, n_dead_tup, last_vacuum, vacuum_count FROM pg_stat_all_tables WHERE relname = 'vacuum_progress_ao_column';
-
-- Perform VACUUM and observe the progress
-- Suspend execution at pre-cleanup phase after truncating both segfiles to their logical EOF.
@@ -71,7 +67,7 @@ SELECT gp_inject_fault('vacuum_ao_post_cleanup_end', 'reset', dbid) FROM gp_segm
-- pg_class and collected stats view should be updated after the 1st VACUUM
1U: SELECT wait_until_dead_tup_change_to('vacuum_progress_ao_column'::regclass::oid, 0);
SELECT relpages, reltuples, relallvisible FROM pg_class where relname = 'vacuum_progress_ao_column';
-SELECT n_live_tup, n_dead_tup, last_vacuum is not null as has_last_vacuum, vacuum_count FROM pg_stat_all_tables WHERE relname = 'vacuum_progress_ao_column';
+SELECT n_live_tup, n_dead_tup, last_vacuum is not null as has_last_vacuum, vacuum_count FROM gp_stat_all_tables WHERE relname = 'vacuum_progress_ao_column' and gp_segment_id = 1;
-- Perform VACUUM again to recycle the remaining awaiting drop segment marked by the previous run.
@@ -99,17 +95,13 @@ SELECT gp_inject_fault('appendonly_after_truncate_segment_file', 'reset', dbid)
-- pg_class and collected stats view should be updated after the 2nd VACUUM
1U: SELECT wait_until_dead_tup_change_to('vacuum_progress_ao_column'::regclass::oid, 0);
SELECT relpages, reltuples, relallvisible FROM pg_class where relname = 'vacuum_progress_ao_column';
-SELECT n_live_tup, n_dead_tup, last_vacuum is not null as has_last_vacuum, vacuum_count FROM pg_stat_all_tables WHERE relname = 'vacuum_progress_ao_column';
+SELECT n_live_tup, n_dead_tup, last_vacuum is not null as has_last_vacuum, vacuum_count FROM gp_stat_all_tables WHERE relname = 'vacuum_progress_ao_column' and gp_segment_id = 1;
1q:
-- Test vacuum worker process is changed at post-cleanup phase due to mirror down.
-- Current behavior is it will clear previous compact phase num_dead_tuples in post-cleanup
-- phase (at injecting point vacuum_ao_post_cleanup_end), which is different from above case
-- in which vacuum worker isn't changed.
-ALTER SYSTEM SET gp_fts_mark_mirror_down_grace_period to 10;
-ALTER SYSTEM SET gp_fts_probe_interval to 10;
-SELECT gp_segment_id, pg_reload_conf() FROM gp_id UNION SELECT gp_segment_id, pg_reload_conf() FROM gp_dist_random('gp_id');
-
DROP TABLE IF EXISTS vacuum_progress_ao_column;
CREATE TABLE vacuum_progress_ao_column(i int, j int);
CREATE INDEX on vacuum_progress_ao_column(i);
@@ -132,7 +124,7 @@ DELETE FROM vacuum_progress_ao_column where j % 2 = 0;
1: set debug_appendonly_print_compaction to on;
1&: vacuum vacuum_progress_ao_column;
-2: SELECT gp_wait_until_triggered_fault('vacuum_ao_after_compact', 3, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+2: SELECT gp_wait_until_triggered_fault('vacuum_ao_after_compact', 1, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
-- Non-zero progressing data num_dead_tuples is showed up.
select gp_segment_id, relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id > -1;
@@ -153,14 +145,14 @@ select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, he
-- initializes a new vacrelstats at the beginning of post-cleanup phase.
-- Also all segments should reach to the same "vacuum_worker_changed" point
-- due to FTS version being changed.
-2: SELECT gp_wait_until_triggered_fault('vacuum_worker_changed', 3, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+2: SELECT gp_wait_until_triggered_fault('vacuum_worker_changed', 1, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
-- now seg1's mirror is marked as down
2: SELECT content, role, preferred_role, mode, status FROM gp_segment_configuration WHERE content > -1;
-- Resume execution and entering post_cleaup phase, suspend at the end of it.
2: SELECT gp_inject_fault('vacuum_ao_post_cleanup_end', 'suspend', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
2: SELECT gp_inject_fault('vacuum_worker_changed', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
-2: SELECT gp_wait_until_triggered_fault('vacuum_ao_post_cleanup_end', 3, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+2: SELECT gp_wait_until_triggered_fault('vacuum_ao_post_cleanup_end', 1, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
-- The previous collected num_dead_tuples in compact phase is zero.
select gp_segment_id, relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id > -1;
@@ -180,6 +172,3 @@ select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, he
SELECT gp_inject_fault_infinite('all', 'reset', dbid) FROM gp_segment_configuration;
reset Debug_appendonly_print_compaction;
reset default_table_access_method;
-ALTER SYSTEM RESET gp_fts_mark_mirror_down_grace_period;
-ALTER SYSTEM RESET gp_fts_probe_interval;
-SELECT gp_segment_id, pg_reload_conf() FROM gp_id UNION SELECT gp_segment_id, pg_reload_conf() FROM gp_dist_random('gp_id');
diff --git a/src/test/isolation2/sql/vacuum_progress_row.sql b/src/test/isolation2/sql/vacuum_progress_row.sql
index 93da2a47bbc..ec4b5a354db 100644
--- a/src/test/isolation2/sql/vacuum_progress_row.sql
+++ b/src/test/isolation2/sql/vacuum_progress_row.sql
@@ -29,11 +29,6 @@ CREATE INDEX on vacuum_progress_ao_row(j);
-- Also delete half of the tuples evenly before the EOF of segno 2.
DELETE FROM vacuum_progress_ao_row where j % 2 = 0;
--- Lookup pg_class and collected stats view before VACUUM
-SELECT relpages, reltuples, relallvisible FROM pg_class where relname = 'vacuum_progress_ao_row';
-SELECT n_live_tup, n_dead_tup, last_vacuum, vacuum_count FROM gp_stat_all_tables WHERE relname = 'vacuum_progress_ao_row' and gp_segment_id = 1;
-SELECT n_live_tup, n_dead_tup, last_vacuum, vacuum_count FROM gp_stat_all_tables_summary WHERE relname = 'vacuum_progress_ao_row';
-
-- Perform VACUUM and observe the progress
-- Suspend execution at pre-cleanup phase after truncating both segfiles to their logical EOF.
@@ -57,7 +52,7 @@ select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, he
-- Resume execution and suspend again after compacting all segfiles
SELECT gp_inject_fault('vacuum_ao_after_compact', 'suspend', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
SELECT gp_inject_fault('appendonly_insert', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
-SELECT gp_wait_until_triggered_fault('vacuum_ao_after_compact', 1, dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+SELECT gp_wait_until_triggered_fault('vacuum_ao_after_compact', 1, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
-- After compacting all segfiles we expect 50000 dead tuples
select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id = 1;
select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum_summary;
@@ -65,7 +60,7 @@ select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, he
-- Resume execution and entering post_cleaup phase, suspend at the end of it.
SELECT gp_inject_fault('vacuum_ao_post_cleanup_end', 'suspend', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
SELECT gp_inject_fault('vacuum_ao_after_compact', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
-SELECT gp_wait_until_triggered_fault('vacuum_ao_post_cleanup_end', 1, dbid) FROM gp_segment_configuration WHERE content = 1 AND role = 'p';
+SELECT gp_wait_until_triggered_fault('vacuum_ao_post_cleanup_end', 1, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
-- We should have skipped recycling the awaiting drop segment because the segment was still visible to the SELECT gp_wait_until_triggered_fault query.
select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id = 1;
select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum_summary;
@@ -76,7 +71,7 @@ SELECT gp_inject_fault('vacuum_ao_post_cleanup_end', 'reset', dbid) FROM gp_segm
-- pg_class and collected stats view should be updated after the 1st VACUUM
1U: SELECT wait_until_dead_tup_change_to('vacuum_progress_ao_row'::regclass::oid, 0);
SELECT relpages, reltuples, relallvisible FROM pg_class where relname = 'vacuum_progress_ao_row';
-SELECT n_live_tup, n_dead_tup, last_vacuum is not null as has_last_vacuum, vacuum_count FROM pg_stat_all_tables WHERE relname = 'vacuum_progress_ao_row';
+SELECT n_live_tup, n_dead_tup, last_vacuum is not null as has_last_vacuum, vacuum_count FROM gp_stat_all_tables WHERE relname = 'vacuum_progress_ao_row' and gp_segment_id = 1;
-- Perform VACUUM again to recycle the remaining awaiting drop segment marked by the previous run.
SELECT gp_inject_fault('vacuum_ao_after_index_delete', 'suspend', dbid) FROM gp_segment_configuration WHERE content = 0 AND role = 'p';
@@ -106,6 +101,77 @@ SELECT relpages, reltuples, relallvisible FROM pg_class where relname = 'vacuum_
SELECT n_live_tup, n_dead_tup, last_vacuum is not null as has_last_vacuum, vacuum_count FROM gp_stat_all_tables WHERE relname = 'vacuum_progress_ao_row' and gp_segment_id = 1;
SELECT n_live_tup, n_dead_tup, last_vacuum is not null as has_last_vacuum, vacuum_count FROM gp_stat_all_tables_summary WHERE relname = 'vacuum_progress_ao_row';
+1q:
+-- Test vacuum worker process is changed at post-cleanup phase due to mirror down.
+-- Current behavior is it will clear previous compact phase num_dead_tuples in post-cleanup
+-- phase (at injecting point vacuum_ao_post_cleanup_end), which is different from above case
+-- in which vacuum worker isn't changed.
+DROP TABLE IF EXISTS vacuum_progress_ao_row;
+CREATE TABLE vacuum_progress_ao_row(i int, j int);
+CREATE INDEX on vacuum_progress_ao_row(i);
+CREATE INDEX on vacuum_progress_ao_row(j);
+1: BEGIN;
+2: BEGIN;
+1: INSERT INTO vacuum_progress_ao_row SELECT i, i FROM generate_series(1, 100000) i;
+2: INSERT INTO vacuum_progress_ao_row SELECT i, i FROM generate_series(1, 100000) i;
+2: COMMIT;
+2: BEGIN;
+2: INSERT INTO vacuum_progress_ao_row SELECT i, i FROM generate_series(1, 100000) i;
+2: ABORT;
+2q:
+1: ABORT;
+DELETE FROM vacuum_progress_ao_row where j % 2 = 0;
+
+-- Suspend execution at the end of compact phase.
+2: SELECT gp_inject_fault('vacuum_ao_after_compact', 'suspend', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+
+1: set debug_appendonly_print_compaction to on;
+1&: vacuum vacuum_progress_ao_row;
+
+2: SELECT gp_wait_until_triggered_fault('vacuum_ao_after_compact', 1, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+
+-- Non-zero progressing data num_dead_tuples is showed up.
+select gp_segment_id, relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id > -1;
+select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum_summary;
+
+-- Resume execution of compact phase and block at syncrep.
+2: SELECT gp_inject_fault_infinite('wal_sender_loop', 'suspend', dbid) FROM gp_segment_configuration WHERE role = 'p' and content = 1;
+2: SELECT gp_inject_fault('vacuum_ao_after_compact', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+-- stop the mirror should turn off syncrep
+2: SELECT pg_ctl(datadir, 'stop', 'immediate') FROM gp_segment_configuration WHERE content=1 AND role = 'm';
+
+-- Resume walsender to detect mirror down and suspend at the beginning
+-- of post-cleanup taken over by a new vacuum worker.
+2: SELECT gp_inject_fault('vacuum_worker_changed', 'suspend', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+-- resume walsender and let it exit so that mirror stop can be detected
+2: SELECT gp_inject_fault_infinite('wal_sender_loop', 'reset', dbid) FROM gp_segment_configuration WHERE role = 'p' and content = 1;
+-- Ensure we enter into the target logic which stops cumulative data but
+-- initializes a new vacrelstats at the beginning of post-cleanup phase.
+-- Also all segments should reach to the same "vacuum_worker_changed" point
+-- due to FTS version being changed.
+2: SELECT gp_wait_until_triggered_fault('vacuum_worker_changed', 1, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+-- now seg1's mirror is marked as down
+2: SELECT content, role, preferred_role, mode, status FROM gp_segment_configuration WHERE content > -1;
+
+-- Resume execution and entering post_cleaup phase, suspend at the end of it.
+2: SELECT gp_inject_fault('vacuum_ao_post_cleanup_end', 'suspend', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+2: SELECT gp_inject_fault('vacuum_worker_changed', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+2: SELECT gp_wait_until_triggered_fault('vacuum_ao_post_cleanup_end', 1, dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+
+-- The previous collected num_dead_tuples in compact phase is zero.
+select gp_segment_id, relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum where gp_segment_id > -1;
+select relid::regclass as relname, phase, heap_blks_total, heap_blks_scanned, heap_blks_vacuumed, index_vacuum_count, max_dead_tuples, num_dead_tuples from gp_stat_progress_vacuum_summary;
+
+2: SELECT gp_inject_fault('vacuum_ao_post_cleanup_end', 'reset', dbid) FROM gp_segment_configuration WHERE content > -1 AND role = 'p';
+
+1<:
+
+-- restore environment
+1: reset debug_appendonly_print_compaction;
+
+2: SELECT pg_ctl_start(datadir, port) FROM gp_segment_configuration WHERE role = 'm' AND content = 1;
+2: SELECT wait_until_all_segments_synchronized();
+
-- Cleanup
SELECT gp_inject_fault_infinite('all', 'reset', dbid) FROM gp_segment_configuration;
reset Debug_appendonly_print_compaction;
diff --git a/src/test/regress/expected/stats.out b/src/test/regress/expected/stats.out
index 104725e68b5..14af415e945 100644
--- a/src/test/regress/expected/stats.out
+++ b/src/test/regress/expected/stats.out
@@ -22,7 +22,7 @@ SELECT t.seq_scan, t.seq_tup_read, t.idx_scan, t.idx_tup_fetch,
(b.heap_blks_read + b.heap_blks_hit) AS heap_blks,
(b.idx_blks_read + b.idx_blks_hit) AS idx_blks,
pg_stat_get_snapshot_timestamp() as snap_ts
- FROM pg_catalog.pg_stat_user_tables AS t,
+ FROM pg_catalog.gp_stat_user_tables_summary AS t,
pg_catalog.pg_statio_user_tables AS b
WHERE t.relname='tenk2' AND b.relname='tenk2';
-- function to wait for counters to advance
@@ -45,17 +45,17 @@ begin
-- check to see if seqscan has been sensed
SELECT (st.seq_scan >= pr.seq_scan + 1) INTO updated1
- FROM pg_stat_user_tables AS st, pg_class AS cl, prevstats AS pr
+ FROM gp_stat_user_tables_summary AS st, pg_class AS cl, prevstats AS pr
WHERE st.relname='tenk2' AND cl.relname='tenk2';
-- check to see if indexscan has been sensed
SELECT (st.idx_scan >= pr.idx_scan + 1) INTO updated2
- FROM pg_stat_user_tables AS st, pg_class AS cl, prevstats AS pr
+ FROM gp_stat_user_tables_summary AS st, pg_class AS cl, prevstats AS pr
WHERE st.relname='tenk2' AND cl.relname='tenk2';
-- check to see if all updates have been sensed
SELECT (n_tup_ins > 0) INTO updated3
- FROM pg_stat_user_tables WHERE relname='trunc_stats_test4';
+ FROM gp_stat_user_tables_summary WHERE relname='trunc_stats_test4';
-- We must also check explicitly that pg_stat_get_snapshot_timestamp has
-- advanced, because that comes from the global stats file which might
@@ -65,7 +65,7 @@ begin
-- check to see if idx_tup_fetch has been sensed
SELECT (st.idx_tup_fetch >= pr.idx_tup_fetch + 1) INTO updated5
- FROM pg_stat_user_tables AS st, pg_class AS cl, prevstats AS pr
+ FROM gp_stat_user_tables_summary AS st, pg_class AS cl, prevstats AS pr
WHERE st.relname='tenk2' AND cl.relname='tenk2';
exit when updated1 and updated2 and updated3 and updated4 and updated5;
@@ -177,7 +177,7 @@ SELECT wait_for_stats();
-- check effects
SELECT relname, n_tup_ins, n_tup_upd, n_tup_del, n_live_tup, n_dead_tup
- FROM pg_stat_user_tables
+ FROM gp_stat_user_tables_summary
WHERE relname like 'trunc_stats_test%' order by relname;
relname | n_tup_ins | n_tup_upd | n_tup_del | n_live_tup | n_dead_tup
-------------------+-----------+-----------+-----------+------------+------------
@@ -192,7 +192,7 @@ SELECT st.seq_scan >= pr.seq_scan + 1,
st.seq_tup_read >= pr.seq_tup_read + cl.reltuples,
st.idx_scan >= pr.idx_scan + 1,
st.idx_tup_fetch >= pr.idx_tup_fetch + 1
- FROM pg_stat_user_tables AS st, pg_class AS cl, prevstats AS pr
+ FROM gp_stat_user_tables_summary AS st, pg_class AS cl, prevstats AS pr
WHERE st.relname='tenk2' AND cl.relname='tenk2';
?column? | ?column? | ?column? | ?column?
----------+----------+----------+----------
diff --git a/src/test/regress/input/pgstat_qd_tabstat.source b/src/test/regress/input/pgstat_qd_tabstat.source
index e9f76ccf0d6..20afcd78afb 100644
--- a/src/test/regress/input/pgstat_qd_tabstat.source
+++ b/src/test/regress/input/pgstat_qd_tabstat.source
@@ -234,8 +234,8 @@ insert into base_table select i,i,i from generate_series(1, 100) i;
refresh materialized view mt;
select pg_sleep(0.77) from gp_dist_random('gp_id'); -- Force pgstat_report_stat() to send tabstat.
select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'mt'::regclass;
--- pg_stat_all_tables collects gpstats across segments
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'mt'::regclass;
+-- gp_stat_all_tables_summary collects gpstats across segments
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from gp_stat_all_tables_summary where relid = 'mt'::regclass;
drop materialized view mt;
drop table base_table;
@@ -250,8 +250,8 @@ insert into base_table select i,i,i from generate_series(1, 100) i;
refresh materialized view mt;
select pg_sleep(0.77) from gp_dist_random('gp_id'); -- Force pgstat_report_stat() to send tabstat.
select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'mt'::regclass;
--- pg_stat_all_tables collects gpstats across segments
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'mt'::regclass;
+-- gp_stat_all_tables_summary collects gpstats across segments
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from gp_stat_all_tables_summary where relid = 'mt'::regclass;
reset gp_autostats_mode;
diff --git a/src/test/regress/output/pgstat_qd_tabstat.source b/src/test/regress/output/pgstat_qd_tabstat.source
index 591f262f7c5..116140f845d 100644
--- a/src/test/regress/output/pgstat_qd_tabstat.source
+++ b/src/test/regress/output/pgstat_qd_tabstat.source
@@ -520,8 +520,8 @@ select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n
153 | 0 | 0 | 0 | 102 | 0 | 153
(1 row)
--- pg_stat_all_tables collects gpstats across segments
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'mt'::regclass;
+-- gp_stat_all_tables_summary collects gpstats across segments
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from gp_stat_all_tables_summary where relid = 'mt'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
153 | 0 | 0 | 0 | 102 | 0 | 153
@@ -561,8 +561,8 @@ select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n
153 | 0 | 0 | 0 | 102 | 0 | 153
(1 row)
--- pg_stat_all_tables collects gpstats across segments
-select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from pg_stat_all_tables where relid = 'mt'::regclass;
+-- gp_stat_all_tables_summary collects gpstats across segments
+select n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup, n_dead_tup, n_mod_since_analyze from gp_stat_all_tables_summary where relid = 'mt'::regclass;
n_tup_ins | n_tup_upd | n_tup_del | n_tup_hot_upd | n_live_tup | n_dead_tup | n_mod_since_analyze
-----------+-----------+-----------+---------------+------------+------------+---------------------
153 | 0 | 0 | 0 | 102 | 0 | 153
diff --git a/src/test/regress/sql/stats.sql b/src/test/regress/sql/stats.sql
index 3acae2fc8a5..0a286a121cd 100644
--- a/src/test/regress/sql/stats.sql
+++ b/src/test/regress/sql/stats.sql
@@ -20,7 +20,7 @@ SELECT t.seq_scan, t.seq_tup_read, t.idx_scan, t.idx_tup_fetch,
(b.heap_blks_read + b.heap_blks_hit) AS heap_blks,
(b.idx_blks_read + b.idx_blks_hit) AS idx_blks,
pg_stat_get_snapshot_timestamp() as snap_ts
- FROM pg_catalog.pg_stat_user_tables AS t,
+ FROM pg_catalog.gp_stat_user_tables_summary AS t,
pg_catalog.pg_statio_user_tables AS b
WHERE t.relname='tenk2' AND b.relname='tenk2';
@@ -44,17 +44,17 @@ begin
-- check to see if seqscan has been sensed
SELECT (st.seq_scan >= pr.seq_scan + 1) INTO updated1
- FROM pg_stat_user_tables AS st, pg_class AS cl, prevstats AS pr
+ FROM gp_stat_user_tables_summary AS st, pg_class AS cl, prevstats AS pr
WHERE st.relname='tenk2' AND cl.relname='tenk2';
-- check to see if indexscan has been sensed
SELECT (st.idx_scan >= pr.idx_scan + 1) INTO updated2
- FROM pg_stat_user_tables AS st, pg_class AS cl, prevstats AS pr
+ FROM gp_stat_user_tables_summary AS st, pg_class AS cl, prevstats AS pr
WHERE st.relname='tenk2' AND cl.relname='tenk2';
-- check to see if all updates have been sensed
SELECT (n_tup_ins > 0) INTO updated3
- FROM pg_stat_user_tables WHERE relname='trunc_stats_test4';
+ FROM gp_stat_user_tables_summary WHERE relname='trunc_stats_test4';
-- We must also check explicitly that pg_stat_get_snapshot_timestamp has
-- advanced, because that comes from the global stats file which might
@@ -64,7 +64,7 @@ begin
-- check to see if idx_tup_fetch has been sensed
SELECT (st.idx_tup_fetch >= pr.idx_tup_fetch + 1) INTO updated5
- FROM pg_stat_user_tables AS st, pg_class AS cl, prevstats AS pr
+ FROM gp_stat_user_tables_summary AS st, pg_class AS cl, prevstats AS pr
WHERE st.relname='tenk2' AND cl.relname='tenk2';
exit when updated1 and updated2 and updated3 and updated4 and updated5;
@@ -167,14 +167,14 @@ SELECT wait_for_stats();
-- check effects
SELECT relname, n_tup_ins, n_tup_upd, n_tup_del, n_live_tup, n_dead_tup
- FROM pg_stat_user_tables
+ FROM gp_stat_user_tables_summary
WHERE relname like 'trunc_stats_test%' order by relname;
SELECT st.seq_scan >= pr.seq_scan + 1,
st.seq_tup_read >= pr.seq_tup_read + cl.reltuples,
st.idx_scan >= pr.idx_scan + 1,
st.idx_tup_fetch >= pr.idx_tup_fetch + 1
- FROM pg_stat_user_tables AS st, pg_class AS cl, prevstats AS pr
+ FROM gp_stat_user_tables_summary AS st, pg_class AS cl, prevstats AS pr
WHERE st.relname='tenk2' AND cl.relname='tenk2';
-- GPDB_13_MERGE_FIXME: Some statistics are handled by stat collector process on each segment but not sent to master.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org