| -- 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 |