mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +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:
@ -101,6 +101,29 @@ SELECT * FROM test WHERE a IN (1, 2, 3, 4, 5);
|
||||
|
||||
SELECT query, calls, rows FROM pg_stat_statements ORDER BY query COLLATE "C";
|
||||
|
||||
--
|
||||
-- INSERT, UPDATE, DELETE on test table to validate WAL generation metrics
|
||||
--
|
||||
SELECT pg_stat_statements_reset();
|
||||
|
||||
-- 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";
|
||||
|
||||
--
|
||||
-- pg_stat_statements.track = none
|
||||
--
|
||||
|
Reference in New Issue
Block a user