mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-08-23 20:57:32 +02:00
89 lines
2.0 KiB
Plaintext
89 lines
2.0 KiB
Plaintext
|
--
|
||
|
-- Information related to planning
|
||
|
--
|
||
|
-- These tests require track_planning to be enabled.
|
||
|
SET pg_stat_statements.track_planning = TRUE;
|
||
|
SELECT pg_stat_statements_reset();
|
||
|
pg_stat_statements_reset
|
||
|
--------------------------
|
||
|
|
||
|
(1 row)
|
||
|
|
||
|
--
|
||
|
-- [re]plan counting
|
||
|
--
|
||
|
CREATE TABLE stats_plan_test ();
|
||
|
PREPARE prep1 AS SELECT COUNT(*) FROM stats_plan_test;
|
||
|
EXECUTE prep1;
|
||
|
count
|
||
|
-------
|
||
|
0
|
||
|
(1 row)
|
||
|
|
||
|
EXECUTE prep1;
|
||
|
count
|
||
|
-------
|
||
|
0
|
||
|
(1 row)
|
||
|
|
||
|
EXECUTE prep1;
|
||
|
count
|
||
|
-------
|
||
|
0
|
||
|
(1 row)
|
||
|
|
||
|
ALTER TABLE stats_plan_test ADD COLUMN x int;
|
||
|
EXECUTE prep1;
|
||
|
count
|
||
|
-------
|
||
|
0
|
||
|
(1 row)
|
||
|
|
||
|
SELECT 42;
|
||
|
?column?
|
||
|
----------
|
||
|
42
|
||
|
(1 row)
|
||
|
|
||
|
SELECT 42;
|
||
|
?column?
|
||
|
----------
|
||
|
42
|
||
|
(1 row)
|
||
|
|
||
|
SELECT 42;
|
||
|
?column?
|
||
|
----------
|
||
|
42
|
||
|
(1 row)
|
||
|
|
||
|
SELECT plans, calls, rows, query FROM pg_stat_statements
|
||
|
WHERE query NOT LIKE 'PREPARE%' ORDER BY query COLLATE "C";
|
||
|
plans | calls | rows | query
|
||
|
-------+-------+------+----------------------------------------------------------
|
||
|
0 | 1 | 0 | ALTER TABLE stats_plan_test ADD COLUMN x int
|
||
|
0 | 1 | 0 | CREATE TABLE stats_plan_test ()
|
||
|
3 | 3 | 3 | SELECT $1
|
||
|
0 | 1 | 1 | SELECT pg_stat_statements_reset()
|
||
|
1 | 0 | 0 | SELECT plans, calls, rows, query FROM pg_stat_statements+
|
||
|
| | | WHERE query NOT LIKE $1 ORDER BY query COLLATE "C"
|
||
|
(5 rows)
|
||
|
|
||
|
-- for the prepared statement we expect at least one replan, but cache
|
||
|
-- invalidations could force more
|
||
|
SELECT plans >= 2 AND plans <= calls AS plans_ok, calls, rows, query FROM pg_stat_statements
|
||
|
WHERE query LIKE 'PREPARE%' ORDER BY query COLLATE "C";
|
||
|
plans_ok | calls | rows | query
|
||
|
----------+-------+------+-------------------------------------------------------
|
||
|
t | 4 | 4 | PREPARE prep1 AS SELECT COUNT(*) FROM stats_plan_test
|
||
|
(1 row)
|
||
|
|
||
|
-- Cleanup
|
||
|
DROP TABLE stats_plan_test;
|
||
|
SELECT pg_stat_statements_reset();
|
||
|
pg_stat_statements_reset
|
||
|
--------------------------
|
||
|
|
||
|
(1 row)
|
||
|
|