|
4 | 4 | -- | -- Create Date : 16 SEPT 2019 |
|
5 | 5 | -- | -- Description : Script to Collect PostgreSQL Database Informations |
|
6 | 6 | -- | and generate HTML Report |
|
7 |
| --- | -- version : V1.2 for PostgreSQL 16 | |
8 |
| --- | -- Changelog : https://github.com/awslabs/pg-collector/blob/pg-collector-for-postgresql-16/CHANGELOG.md | |
| 7 | +-- | -- version : V1 for PostgreSQL 17 | |
| 8 | +-- | -- Changelog : https://github.com/awslabs/pg-collector/blob/pg-collector-for-postgresql-17/CHANGELOG.md | |
9 | 9 | -- | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
|
10 | 10 | -- | SPDX-License-Identifier: MIT-0 |
|
11 | 11 | -- +-------------------------------------------------------------------------------------------------------------+
|
|
61 | 61 | \qecho font:bold 10pt Arial,Helvetica,sans-serif;
|
62 | 62 | \qecho color:green; }
|
63 | 63 | \qecho </style>
|
64 |
| -\qecho <h1 align="center" style="background-color:#e59003" >PG COLLECTOR V1.2 for PostgreSQL 16</h1> |
65 |
| -\qecho <font size="+1" face="Arial,Helvetica,Geneva,sans-serif" color="#16191f"><a href="https://github.com/awslabs/pg-collector/tree/pg-collector-for-postgresql-16" target="_blank">For more information about PG Collector, visit the project github repository</a></font><hr align="left" > |
| 64 | +\qecho <h1 align="center" style="background-color:#e59003" >PG COLLECTOR V1 for PostgreSQL 17</h1> |
| 65 | +\qecho <font size="+1" face="Arial,Helvetica,Geneva,sans-serif" color="#16191f"><a href="https://github.com/awslabs/pg-collector/tree/pg-collector-for-postgresql-17" target="_blank">For more information about PG Collector, visit the project github repository</a></font><hr align="left" > |
66 | 66 | \qecho <font size="+2" face="Arial,Helvetica,Geneva,sans-serif" color="#16191f"><b>DB INFO</b></font><hr align="left" width="150">
|
67 | 67 | \qecho <br>
|
68 | 68 | \qecho 'PG Host Name / PG RDS ENDPOINT: ':HOST
|
@@ -313,9 +313,11 @@ SELECT p.pid, now() - a.xact_start AS duration, coalesce(wait_event_type ||'.'||
|
313 | 313 | round(100.0 * p.heap_blks_scanned / p.heap_blks_total, 1) AS scanned_pct,
|
314 | 314 | round(100.0 * p.heap_blks_vacuumed / p.heap_blks_total, 1) AS vacuumed_pct,
|
315 | 315 | p.index_vacuum_count,
|
316 |
| - p.max_dead_tuples as max_dead_tuples_per_cycle, |
| 316 | + p.max_dead_tuple_bytes as dead_tuple_data_per_cycle, |
317 | 317 | s.n_dead_tup as total_num_dead_tuples ,
|
318 |
| - ceil(s.n_dead_tup::float/p.max_dead_tuples::float) index_cycles_required |
| 318 | + indexes_total as total_indexes_to_vacuum, |
| 319 | + indexes_processed as total_indexes_processed, |
| 320 | + ceil(p.dead_tuple_bytes::float/p.max_dead_tuple_bytes::float) index_cycles_required |
319 | 321 | FROM pg_stat_progress_vacuum p JOIN pg_stat_activity a using (pid)
|
320 | 322 | join pg_stat_all_tables s on s.relid = p.relid
|
321 | 323 | ORDER BY now() - a.xact_start DESC;
|
@@ -619,7 +621,24 @@ now() - pg_stat_activity.query_start AS duration,
|
619 | 621 | \qecho <h3>Vacuum progress:</h3>
|
620 | 622 | \qecho <br>
|
621 | 623 | \qecho <details>
|
622 |
| -SELECT p.pid, now() - a.xact_start AS duration, coalesce(wait_event_type ||'.'|| wait_event, 'f') AS waiting, CASE WHEN a.query ~ '^autovacuum.*to prevent wraparound' THEN 'wraparound' WHEN a.query ~ '^vacuum' THEN 'user' ELSE 'regular' END AS mode, p.datname AS database, p.relid::regclass AS table, p.phase, pg_size_pretty(p.heap_blks_total * current_setting('block_size')::int) AS table_size, pg_size_pretty(pg_total_relation_size(relid)) AS total_size, pg_size_pretty(p.heap_blks_scanned * current_setting('block_size')::int) AS scanned, pg_size_pretty(p.heap_blks_vacuumed * current_setting('block_size')::int) AS vacuumed, round(100.0 * p.heap_blks_scanned / p.heap_blks_total, 1) AS scanned_pct, round(100.0 * p.heap_blks_vacuumed / p.heap_blks_total, 1) AS vacuumed_pct, p.index_vacuum_count, round(100.0 * p.num_dead_tuples / p.max_dead_tuples,1) AS dead_pct FROM pg_stat_progress_vacuum p JOIN pg_stat_activity a using (pid) ORDER BY now() - a.xact_start DESC; |
| 624 | +SELECT p.pid, now() - a.xact_start AS duration, coalesce(wait_event_type ||'.'|| wait_event, 'f') AS waiting, |
| 625 | + CASE WHEN a.query ~ '^autovacuum.*to prevent wraparound' THEN 'wraparound' WHEN a.query ~ '^vacuum' THEN 'user' ELSE 'regular' END AS mode, |
| 626 | + p.datname AS database, p.relid::regclass AS table, p.phase, a.query , |
| 627 | + pg_size_pretty(p.heap_blks_total * current_setting('block_size')::int) AS table_size, |
| 628 | + pg_size_pretty(pg_total_relation_size(p.relid)) AS total_size, |
| 629 | + pg_size_pretty(p.heap_blks_scanned * current_setting('block_size')::int) AS scanned, |
| 630 | + pg_size_pretty(p.heap_blks_vacuumed * current_setting('block_size')::int) AS vacuumed, |
| 631 | + round(100.0 * p.heap_blks_scanned / p.heap_blks_total, 1) AS scanned_pct, |
| 632 | + round(100.0 * p.heap_blks_vacuumed / p.heap_blks_total, 1) AS vacuumed_pct, |
| 633 | + p.index_vacuum_count, |
| 634 | + p.max_dead_tuple_bytes as dead_tuple_data_per_cycle, |
| 635 | + s.n_dead_tup as total_num_dead_tuples , |
| 636 | + indexes_total as total_indexes_to_vacuum, |
| 637 | + indexes_processed as total_indexes_processed, |
| 638 | + ceil(p.dead_tuple_bytes::float/p.max_dead_tuple_bytes::float) index_cycles_required |
| 639 | +FROM pg_stat_progress_vacuum p JOIN pg_stat_activity a using (pid) |
| 640 | + join pg_stat_all_tables s on s.relid = p.relid |
| 641 | +ORDER BY now() - a.xact_start DESC; |
623 | 642 | \qecho </details>
|
624 | 643 | \qecho <br>
|
625 | 644 | \qecho <h3>Autovacuum progress per day: </h3>
|
@@ -1011,6 +1030,8 @@ round(stddev_exec_time::numeric, 2) as standard_deviation_time_Msec,
|
1011 | 1030 | round((stddev_exec_time::numeric/1000), 2) as standard_deviation_time_sec,
|
1012 | 1031 | round(rows::numeric/calls,2) rows_per_exec,
|
1013 | 1032 | round((100 * total_exec_time / sum(total_exec_time) over ())::numeric, 4) as percent,
|
| 1033 | +round((shared_blk_read_time::numeric/1000),2) as shared_blocks_read_time_sec, |
| 1034 | +shared_blks_hit as shared_blocks_hits, |
1014 | 1035 | shared_blks_read
|
1015 | 1036 | from pg_stat_statements
|
1016 | 1037 | order by shared_blks_read desc limit 20;
|
|
0 commit comments