Skip to content

Commit 5acd6b6

Browse files
committed
pg-collector V1 for PostgreSQL 17
1 parent f223858 commit 5acd6b6

File tree

2 files changed

+35
-29
lines changed

2 files changed

+35
-29
lines changed

CHANGELOG.md

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,11 @@ All notable changes to pg collector will be documented in this file.
66
# V1
77

88
```
9-
1- V1 version Created from pg-collector-for-postgresQL-15 branch.
10-
2- Change the supported postgresql version from 15 to 16.
11-
3- Add reserved_connections parameter to Reserved connections settings.
9+
1- V1 version created from pg-collector-for-postgresQL-16 branch.
10+
2- Change the supported postgresql version from 16 to 17
11+
3- Fix "ERROR: column p.max_dead_tuples does not exist" and "ERROR: column p.num_dead_tuples does not exist" by changing the columns "max_dead_tuples" and "num_dead_tuples" to the newly introduced columns "max_dead_tuple_bytes" and "dead_tuple_bytes" : https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=667e65aac354975c6f8090c6146fceb8d7b762d6
12+
4- Added new columns "total_indexes_to_vacuum" and "total_indexes_processed" to "vacuum progress process" table.
13+
5- Added new columns to "Top SQL order by shared blocks read (physical reads)" table
14+
"shared_blocks_hits"
15+
"shared_blocks_read_time_sec"
1216
```
13-
14-
# V1.1
15-
16-
```
17-
1- The script should display the message "Report Generated Successfully" upon successful completion and relocate the report file name and location information to the end of the script..
18-
2- Add a new section for Amazon Aurora PostgreSQL.
19-
3- Add a new section for Invalid databases.
20-
4- Implement a check for the pg_stat_statements extension. If the extension is not installed, the script should print the message "pg_stat_statements extension is not installed" in the report, instead of displaying the errors "ERROR: relation "pg_stat_statements_info" does not exist" or "ERROR: relation "pg_stat_statements" does not exist".
21-
5- Add a new section "List of role grants" under "Users & Roles Info".
22-
```
23-
24-
25-
# V1.2
26-
27-
```
28-
1- Add a new section for Amazon Aurora Limitless Database.
29-
2- Starting from this version, the pg collector will not include Amazon Aurora PostgreSQL or Amazon Aurora Limitless Database sections automatically in the pg collector report if the instance is not an Amazon Aurora.
30-
31-
```

pg_collector.sql

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
-- | -- Create Date : 16 SEPT 2019 |
55
-- | -- Description : Script to Collect PostgreSQL Database Informations |
66
-- | 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 |
99
-- | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
1010
-- | SPDX-License-Identifier: MIT-0 |
1111
-- +-------------------------------------------------------------------------------------------------------------+
@@ -61,8 +61,8 @@
6161
\qecho font:bold 10pt Arial,Helvetica,sans-serif;
6262
\qecho color:green; }
6363
\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" >
6666
\qecho <font size="+2" face="Arial,Helvetica,Geneva,sans-serif" color="#16191f"><b>DB INFO</b></font><hr align="left" width="150">
6767
\qecho <br>
6868
\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 ||'.'||
313313
round(100.0 * p.heap_blks_scanned / p.heap_blks_total, 1) AS scanned_pct,
314314
round(100.0 * p.heap_blks_vacuumed / p.heap_blks_total, 1) AS vacuumed_pct,
315315
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,
317317
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
319321
FROM pg_stat_progress_vacuum p JOIN pg_stat_activity a using (pid)
320322
join pg_stat_all_tables s on s.relid = p.relid
321323
ORDER BY now() - a.xact_start DESC;
@@ -619,7 +621,24 @@ now() - pg_stat_activity.query_start AS duration,
619621
\qecho <h3>Vacuum progress:</h3>
620622
\qecho <br>
621623
\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;
623642
\qecho </details>
624643
\qecho <br>
625644
\qecho <h3>Autovacuum progress per day: </h3>
@@ -1011,6 +1030,8 @@ round(stddev_exec_time::numeric, 2) as standard_deviation_time_Msec,
10111030
round((stddev_exec_time::numeric/1000), 2) as standard_deviation_time_sec,
10121031
round(rows::numeric/calls,2) rows_per_exec,
10131032
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,
10141035
shared_blks_read
10151036
from pg_stat_statements
10161037
order by shared_blks_read desc limit 20;

0 commit comments

Comments
 (0)