-- Counters measured by the executor and at transaction end. SELECT pga_test_role('t_exec'); pga_test_role --------------- (1 row) CREATE TABLE big (id int); INSERT INTO big SELECT generate_series(1, 2000); -- big_table_rows = 1000 CREATE TABLE small (id int PRIMARY KEY); INSERT INTO small SELECT generate_series(1, 10); ANALYZE big, small; GRANT SELECT ON big, small TO t_exec; SET ROLE t_exec; \set QUIET on -- seqscan_big: only a sequential scan of a big table counts SET enable_indexscan = off; SET enable_bitmapscan = off; SELECT count(*) FROM small; NOTICE: [BRONZE] Achievement unlocked: Hello, World (+10) DETAIL: Run your first SELECT. Total score: 10. Unlocked by 4 of 4 players (100%). count ------- 10 (1 row) SELECT count(*) FROM big; NOTICE: [GOLD] Achievement unlocked: Indexes Are for the Weak (+50) DETAIL: Scan a table of a million rows sequentially. Total score: 60. You are the first of 4 players to unlock it. count ------- 2000 (1 row) RESET enable_indexscan; RESET enable_bitmapscan; -- query_over_60s / query_over_1h: durations are shifted in the test build SET pg_achievements.test_time_shift = '61s'; SELECT 1 AS slow; NOTICE: [SILVER] Achievement unlocked: Patient (+25) DETAIL: Wait for a query that runs longer than a minute. Total score: 85. You are the first of 4 players to unlock it. slow ------ 1 (1 row) SET pg_achievements.test_time_shift = '3601s'; SELECT 1 AS very_slow; NOTICE: [GOLD] Achievement unlocked: Marathon (+50) DETAIL: Wait for a query that runs longer than an hour. Total score: 135. You are the first of 4 players to unlock it. very_slow ----------- 1 (1 row) -- rollback_long_xact: only ROLLBACK (or abort) of an old transaction BEGIN; SELECT 1; ?column? ---------- 1 (1 row) COMMIT; BEGIN; SELECT 1; ?column? ---------- 1 (1 row) ROLLBACK; NOTICE: [BRONZE] Achievement unlocked: Ctrl+Z (+10) DETAIL: Roll back a transaction with ROLLBACK. Total score: 145. Unlocked by 3 of 4 players (75%). NOTICE: [GOLD] Achievement unlocked: Time Machine (+50) DETAIL: Roll back a transaction that ran for over an hour. Total score: 195. You are the first of 4 players to unlock it. RESET pg_achievements.test_time_shift; BEGIN; ROLLBACK; -- rows_processed: rows returned by top-level queries (10 + 1 here) SELECT id FROM small; id ---- 1 2 3 4 5 6 7 8 9 10 (10 rows) SELECT 1 FROM small WHERE id = 1; ?column? ---------- 1 (1 row) -- a prepared statement counts every time it runs, also in later -- transactions, and EXECUTE counts like the statement itself: 3 more of -- stmt_select, cte_any 3, a join, 3 more rows PREPARE p AS WITH s AS (SELECT id FROM small) SELECT count(*) FROM s JOIN small USING (id); EXECUTE p; NOTICE: [BRONZE] Achievement unlocked: WITH Love (+10) DETAIL: Run a query with a common table expression. Total score: 205. Unlocked by 2 of 4 players (50%). NOTICE: [BRONZE] Achievement unlocked: All Connected (+10) DETAIL: Run a query with an explicit JOIN. Total score: 215. Unlocked by 2 of 4 players (50%). count ------- 10 (1 row) EXECUTE p; count ------- 10 (1 row) BEGIN; EXECUTE p; count ------- 10 (1 row) COMMIT; DEALLOCATE p; \set QUIET off SELECT * FROM pga_counters(); key | value --------------------+------- cte_any | 3 join_count_max | 1 query_over_1h | 3 query_over_60s | 4 rollback | 2 rollback_long_xact | 1 rows_processed | 20 select_star | 1 seqscan_big | 1 stmt_select | 11 streak_days | 1 (11 rows) RESET ROLE; RESET