mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +03:00
pg_stat_statements: track number of rows processed by some utility commands.
This commit makes pg_stat_statements track the total number of rows retrieved or affected by CREATE TABLE AS, SELECT INTO, CREATE MATERIALIZED VIEW and FETCH commands. Suggested-by: Pascal Legrand Author: Fujii Masao Reviewed-by: Asif Rehman Discussion: https://postgr.es/m/1584293755198-0.post@n3.nabble.com
This commit is contained in:
@ -250,6 +250,30 @@ DROP FUNCTION PLUS_TWO(INTEGER);
|
||||
|
||||
SELECT query, calls, rows FROM pg_stat_statements ORDER BY query COLLATE "C";
|
||||
|
||||
--
|
||||
-- Track the total number of rows retrieved or affected by the utility
|
||||
-- commands of COPY, FETCH, CREATE TABLE AS, CREATE MATERIALIZED VIEW
|
||||
-- and SELECT INTO
|
||||
--
|
||||
SELECT pg_stat_statements_reset();
|
||||
|
||||
CREATE TABLE pgss_ctas AS SELECT a, 'ctas' b FROM generate_series(1, 10) a;
|
||||
SELECT generate_series(1, 10) c INTO pgss_select_into;
|
||||
COPY pgss_ctas (a, b) FROM STDIN;
|
||||
11 copy
|
||||
12 copy
|
||||
13 copy
|
||||
\.
|
||||
CREATE MATERIALIZED VIEW pgss_matv AS SELECT * FROM pgss_ctas;
|
||||
BEGIN;
|
||||
DECLARE pgss_cursor CURSOR FOR SELECT * FROM pgss_matv;
|
||||
FETCH NEXT pgss_cursor;
|
||||
FETCH FORWARD 5 pgss_cursor;
|
||||
FETCH FORWARD ALL pgss_cursor;
|
||||
COMMIT;
|
||||
|
||||
SELECT query, plans, calls, rows FROM pg_stat_statements ORDER BY query COLLATE "C";
|
||||
|
||||
--
|
||||
-- Track user activity and reset them
|
||||
--
|
||||
@ -313,6 +337,9 @@ SELECT query, calls, rows FROM pg_stat_statements ORDER BY query COLLATE "C";
|
||||
--
|
||||
DROP ROLE regress_stats_user1;
|
||||
DROP ROLE regress_stats_user2;
|
||||
DROP MATERIALIZED VIEW pgss_matv;
|
||||
DROP TABLE pgss_ctas;
|
||||
DROP TABLE pgss_select_into;
|
||||
|
||||
--
|
||||
-- [re]plan counting
|
||||
|
Reference in New Issue
Block a user