2 -- Validate WAL generation metrics
4 SET pg_stat_statements.track_utility = FALSE;
5 CREATE TABLE pgss_wal_tab (a int, b char(20));
6 INSERT INTO pgss_wal_tab VALUES(generate_series(1, 10), 'aaa');
7 UPDATE pgss_wal_tab SET b = 'bbb' WHERE a > 7;
8 DELETE FROM pgss_wal_tab WHERE a > 9;
9 DROP TABLE pgss_wal_tab;
10 -- Check WAL is generated for the above statements
11 SELECT query, calls, rows,
12 wal_bytes > 0 as wal_bytes_generated,
13 wal_records > 0 as wal_records_generated,
14 wal_records >= rows as wal_records_ge_rows
15 FROM pg_stat_statements ORDER BY query COLLATE "C";
16 query | calls | rows | wal_bytes_generated | wal_records_generated | wal_records_ge_rows
17 --------------------------------------------------------------+-------+------+---------------------+-----------------------+---------------------
18 DELETE FROM pgss_wal_tab WHERE a > $1 | 1 | 1 | t | t | t
19 INSERT INTO pgss_wal_tab VALUES(generate_series($1, $2), $3) | 1 | 10 | t | t | t
20 SELECT pg_stat_statements_reset() IS NOT NULL AS t | 1 | 1 | f | f | f
21 SET pg_stat_statements.track_utility = $1 | 1 | 0 | f | f | t
22 UPDATE pgss_wal_tab SET b = $1 WHERE a > $2 | 1 | 3 | t | t | t
25 SELECT pg_stat_statements_reset() IS NOT NULL AS t;