mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Allow pg_stat_statements to track WAL usage statistics.
This commit adds three new columns in pg_stat_statements output to display WAL usage statistics added by commitdf3b181499
. This commit doesn't bump the version of pg_stat_statements as the same is done for this release in commit17e0328224
. Author: Kirill Bychik and Julien Rouhaud Reviewed-by: Julien Rouhaud, Fujii Masao, Dilip Kumar and Amit Kapila Discussion: https://postgr.es/m/CAB-hujrP8ZfUkvL5OYETipQwA=e3n7oqHFU=4ZLxWS_Cza3kQQ@mail.gmail.com
This commit is contained in:
@ -211,6 +211,45 @@ SELECT query, calls, rows FROM pg_stat_statements ORDER BY query COLLATE "C";
|
||||
UPDATE test SET b = $1 WHERE a > $2 | 1 | 3
|
||||
(10 rows)
|
||||
|
||||
--
|
||||
-- INSERT, UPDATE, DELETE on test table to validate WAL generation metrics
|
||||
--
|
||||
SELECT pg_stat_statements_reset();
|
||||
pg_stat_statements_reset
|
||||
--------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- utility "create table" should not be shown
|
||||
CREATE TABLE pgss_test (a int, b char(20));
|
||||
INSERT INTO pgss_test VALUES(generate_series(1, 10), 'aaa');
|
||||
UPDATE pgss_test SET b = 'bbb' WHERE a > 7;
|
||||
DELETE FROM pgss_test WHERE a > 9;
|
||||
-- DROP test table
|
||||
SET pg_stat_statements.track_utility = TRUE;
|
||||
DROP TABLE pgss_test;
|
||||
SET pg_stat_statements.track_utility = FALSE;
|
||||
-- Check WAL is generated for the above statements
|
||||
SELECT query, calls, rows,
|
||||
wal_bytes > 0 as wal_bytes_generated,
|
||||
wal_records > 0 as wal_records_generated,
|
||||
wal_records = rows as wal_records_as_rows
|
||||
FROM pg_stat_statements ORDER BY query COLLATE "C";
|
||||
query | calls | rows | wal_bytes_generated | wal_records_generated | wal_records_as_rows
|
||||
-----------------------------------------------------------+-------+------+---------------------+-----------------------+---------------------
|
||||
DELETE FROM pgss_test WHERE a > $1 | 1 | 1 | t | t | t
|
||||
DROP TABLE pgss_test | 1 | 0 | t | t | f
|
||||
INSERT INTO pgss_test VALUES(generate_series($1, $2), $3) | 1 | 10 | t | t | t
|
||||
SELECT pg_stat_statements_reset() | 1 | 1 | f | f | f
|
||||
SELECT query, calls, rows, +| 0 | 0 | f | f | t
|
||||
wal_bytes > $1 as wal_bytes_generated, +| | | | |
|
||||
wal_records > $2 as wal_records_generated, +| | | | |
|
||||
wal_records = rows as wal_records_as_rows +| | | | |
|
||||
FROM pg_stat_statements ORDER BY query COLLATE "C" | | | | |
|
||||
SET pg_stat_statements.track_utility = FALSE | 1 | 0 | f | f | t
|
||||
UPDATE pgss_test SET b = $1 WHERE a > $2 | 1 | 3 | t | t | t
|
||||
(7 rows)
|
||||
|
||||
--
|
||||
-- pg_stat_statements.track = none
|
||||
--
|
||||
|
Reference in New Issue
Block a user