|
| 1 | +/* |
| 2 | + * Greenplum System Summary Views |
| 3 | + * |
| 4 | + * Portions Copyright (c) 2006-2010, Greenplum inc. |
| 5 | + * Portions Copyright (c) 2012-Present VMware, Inc. or its affiliates. |
| 6 | + * Copyright (c) 1996-2019, PostgreSQL Global Development Group |
| 7 | + * |
| 8 | + * src/backend/catalog/system_views_gp_summary.sql |
| 9 | + * |
| 10 | +
|
| 11 | + * This file contains summary views for various Greenplum system catalog |
| 12 | + * views. These summary views are designed to provide aggregated or averaged |
| 13 | + * information for partitioned and replicated tables, considering multiple |
| 14 | + * segments in a Greenplum database. |
| 15 | + * |
| 16 | + * Note: this file is read in single-user -j mode, which means that the |
| 17 | + * command terminator is semicolon-newline-newline; whenever the backend |
| 18 | + * sees that, it stops and executes what it's got. If you write a lot of |
| 19 | + * statements without empty lines between, they'll all get quoted to you |
| 20 | + * in any error message about one of them, so don't do that. Also, you |
| 21 | + * cannot write a semicolon immediately followed by an empty line in a |
| 22 | + * string literal (including a function body!) or a multiline comment. |
| 23 | + */ |
| 24 | + |
| 25 | +CREATE VIEW gp_stat_progress_vacuum_summary AS |
| 26 | +SELECT |
| 27 | + max(coalesce(a1.pid, 0)) as pid, |
| 28 | + a.datid, |
| 29 | + a.datname, |
| 30 | + a.relid, |
| 31 | + a.phase, |
| 32 | + case when d.policytype = 'r' then (sum(a.heap_blks_total)/d.numsegments)::bigint else sum(a.heap_blks_total) end heap_blks_total, |
| 33 | + case when d.policytype = 'r' then (sum(a.heap_blks_scanned)/d.numsegments)::bigint else sum(a.heap_blks_scanned) end heap_blks_scanned, |
| 34 | + case when d.policytype = 'r' then (sum(a.heap_blks_vacuumed)/d.numsegments)::bigint else sum(a.heap_blks_vacuumed) end heap_blks_vacuumed, |
| 35 | + case when d.policytype = 'r' then (sum(a.index_vacuum_count)/d.numsegments)::bigint else sum(a.index_vacuum_count) end index_vacuum_count, |
| 36 | + case when d.policytype = 'r' then (sum(a.max_dead_tuples)/d.numsegments)::bigint else sum(a.max_dead_tuples) end max_dead_tuples, |
| 37 | + case when d.policytype = 'r' then (sum(a.num_dead_tuples)/d.numsegments)::bigint else sum(a.num_dead_tuples) end num_dead_tuples |
| 38 | +FROM gp_stat_progress_vacuum a |
| 39 | + JOIN pg_class c ON a.relid = c.oid |
| 40 | + LEFT JOIN gp_distribution_policy d ON c.oid = d.localoid |
| 41 | + LEFT JOIN gp_stat_progress_vacuum a1 ON a.pid = a1.pid AND a1.gp_segment_id = -1 |
| 42 | +WHERE a.gp_segment_id > -1 |
| 43 | +GROUP BY a.datid, a.datname, a.relid, a.phase, d.policytype, d.numsegments; |
| 44 | + |
| 45 | +CREATE OR REPLACE VIEW gp_stat_progress_analyze_summary AS |
| 46 | +SELECT |
| 47 | + max(coalesce(a1.pid, 0)) as pid, |
| 48 | + a.datid, |
| 49 | + a.datname, |
| 50 | + a.relid, |
| 51 | + a.phase, |
| 52 | + case when d.policytype = 'r' then (sum(a.sample_blks_total)/d.numsegments)::bigint else sum(a.sample_blks_total) end sample_blks_total, |
| 53 | + case when d.policytype = 'r' then (sum(a.sample_blks_scanned)/d.numsegments)::bigint else sum(a.sample_blks_scanned) end sample_blks_scanned, |
| 54 | + case when d.policytype = 'r' then (sum(a.ext_stats_total)/d.numsegments)::bigint else sum(a.ext_stats_total) end ext_stats_total, |
| 55 | + case when d.policytype = 'r' then (sum(a.ext_stats_computed)/d.numsegments)::bigint else sum(a.ext_stats_computed) end ext_stats_computed, |
| 56 | + case when d.policytype = 'r' then (sum(a.child_tables_total)/d.numsegments)::bigint else sum(a.child_tables_total) end child_tables_total, |
| 57 | + case when d.policytype = 'r' then (sum(a.child_tables_done)/d.numsegments)::bigint else sum(a.child_tables_done) end child_tables_done |
| 58 | +FROM gp_stat_progress_analyze a |
| 59 | + JOIN pg_class c ON a.relid = c.oid |
| 60 | + LEFT JOIN gp_distribution_policy d ON c.oid = d.localoid |
| 61 | + LEFT JOIN gp_stat_progress_analyze a1 ON a.pid = a1.pid AND a1.gp_segment_id = -1 |
| 62 | +WHERE a.gp_segment_id > -1 |
| 63 | +GROUP BY a.datid, a.datname, a.relid, a.phase, d.policytype, d.numsegments; |
| 64 | + |
| 65 | +CREATE OR REPLACE VIEW gp_stat_progress_cluster_summary AS |
| 66 | +SELECT |
| 67 | + max(coalesce(a1.pid, 0)) as pid, |
| 68 | + a.datid, |
| 69 | + a.datname, |
| 70 | + a.relid, |
| 71 | + a.command, |
| 72 | + a.phase, |
| 73 | + a.cluster_index_relid, |
| 74 | + case when d.policytype = 'r' then (sum(a.heap_tuples_scanned)/d.numsegments)::bigint else sum(a.heap_tuples_scanned) end heap_tuples_scanned, |
| 75 | + case when d.policytype = 'r' then (sum(a.heap_tuples_written)/d.numsegments)::bigint else sum(a.heap_tuples_written) end heap_tuples_written, |
| 76 | + case when d.policytype = 'r' then (sum(a.heap_blks_total)/d.numsegments)::bigint else sum(a.heap_blks_total) end heap_blks_total, |
| 77 | + case when d.policytype = 'r' then (sum(a.heap_blks_scanned)/d.numsegments)::bigint else sum(a.heap_blks_scanned) end heap_blks_scanned, |
| 78 | + case when d.policytype = 'r' then (sum(a.index_rebuild_count)/d.numsegments)::bigint else sum(a.index_rebuild_count) end index_rebuild_count |
| 79 | +FROM gp_stat_progress_cluster a |
| 80 | + JOIN pg_class c ON a.relid = c.oid |
| 81 | + LEFT JOIN gp_distribution_policy d ON c.oid = d.localoid |
| 82 | + LEFT JOIN gp_stat_progress_cluster a1 ON a.pid = a1.pid AND a1.gp_segment_id = -1 |
| 83 | +WHERE a.gp_segment_id > -1 |
| 84 | +GROUP BY a.datid, a.datname, a.relid, a.command, a.phase, a.cluster_index_relid, d.policytype, d.numsegments; |
| 85 | + |
| 86 | +CREATE OR REPLACE VIEW gp_stat_progress_create_index_summary AS |
| 87 | +SELECT |
| 88 | + max(coalesce(a1.pid, 0)) as pid, |
| 89 | + a.datid, |
| 90 | + a.datname, |
| 91 | + a.relid, |
| 92 | + a.index_relid, |
| 93 | + a.command, |
| 94 | + a.phase, |
| 95 | + case when d.policytype = 'r' then (sum(a.lockers_total)/d.numsegments)::bigint else sum(a.lockers_total) end lockers_total, |
| 96 | + case when d.policytype = 'r' then (sum(a.lockers_done)/d.numsegments)::bigint else sum(a.lockers_done) end lockers_done, |
| 97 | + max(a.current_locker_pid) as current_locker_pid, |
| 98 | + case when d.policytype = 'r' then (sum(a.blocks_total)/d.numsegments)::bigint else sum(a.blocks_total) end blocks_total, |
| 99 | + case when d.policytype = 'r' then (sum(a.blocks_done)/d.numsegments)::bigint else sum(a.blocks_done) end blocks_done, |
| 100 | + case when d.policytype = 'r' then (sum(a.tuples_total)/d.numsegments)::bigint else sum(a.tuples_total) end tuples_total, |
| 101 | + case when d.policytype = 'r' then (sum(a.tuples_done)/d.numsegments)::bigint else sum(a.tuples_done) end tuples_done, |
| 102 | + case when d.policytype = 'r' then (sum(a.partitions_total)/d.numsegments)::bigint else sum(a.partitions_total) end partitions_total, |
| 103 | + case when d.policytype = 'r' then (sum(a.partitions_done)/d.numsegments)::bigint else sum(a.partitions_done) end partitions_done |
| 104 | +FROM gp_stat_progress_create_index a |
| 105 | + JOIN pg_class c ON a.relid = c.oid |
| 106 | + LEFT JOIN gp_distribution_policy d ON c.oid = d.localoid |
| 107 | + LEFT JOIN gp_stat_progress_create_index a1 ON a.pid = a1.pid AND a1.gp_segment_id = -1 |
| 108 | +WHERE a.gp_segment_id > -1 |
| 109 | +GROUP BY a.datid, a.datname, a.relid, a.index_relid, a.command, a.phase, d.policytype, d.numsegments; |
0 commit comments