summaryrefslogtreecommitdiff
path: root/contrib/pg_stat_statements/sql
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2023-08-27 17:27:44 +0900
committerMichael Paquier <michael@paquier.xyz>2023-08-27 17:27:44 +0900
commitbb45156f342c2cdb88cdd7f9efdc4541e910ec86 (patch)
tree630d2e17fc3afab41b7c5ddcda653628a7f2fddd /contrib/pg_stat_statements/sql
parente48b19c5db3185e1868391176fc040df08a149fb (diff)
Show names of DEALLOCATE as constants in pg_stat_statements
This commit switches query jumbling so as prepared statement names are treated as constants in DeallocateStmt. A boolean field is added to DeallocateStmt to make a distinction between ALL and named prepared statements, as "name" was used to make this difference before, NULL meaning DEALLOCATE ALL. Prior to this commit, DEALLOCATE was not tracked in pg_stat_statements, for the reason that it was not possible to treat its name parameter as a constant. Now that query jumbling applies to all the utility nodes, this reason does not apply anymore. Like 638d42a3c520, this can be a huge advantage for monitoring where prepared statement names are randomly generated, preventing bloat in pg_stat_statements. A couple of tests are added to track the new behavior. Author: Dagfinn Ilmari Mannsåker, Michael Paquier Reviewed-by: Julien Rouhaud Discussion: https://postgr.es/m/ZMhT9kNtJJsHw6jK@paquier.xyz
Diffstat (limited to 'contrib/pg_stat_statements/sql')
-rw-r--r--contrib/pg_stat_statements/sql/utility.sql13
1 files changed, 13 insertions, 0 deletions
diff --git a/contrib/pg_stat_statements/sql/utility.sql b/contrib/pg_stat_statements/sql/utility.sql
index 87666d9135f..5f7d4a467f0 100644
--- a/contrib/pg_stat_statements/sql/utility.sql
+++ b/contrib/pg_stat_statements/sql/utility.sql
@@ -237,6 +237,19 @@ DROP DOMAIN domain_stats;
SELECT calls, rows, query FROM pg_stat_statements ORDER BY query COLLATE "C";
SELECT pg_stat_statements_reset();
+-- Execution statements
+SELECT 1 as a;
+PREPARE stat_select AS SELECT $1 AS a;
+EXECUTE stat_select (1);
+DEALLOCATE stat_select;
+PREPARE stat_select AS SELECT $1 AS a;
+EXECUTE stat_select (2);
+DEALLOCATE PREPARE stat_select;
+DEALLOCATE ALL;
+DEALLOCATE PREPARE ALL;
+SELECT calls, rows, query FROM pg_stat_statements ORDER BY query COLLATE "C";
+SELECT pg_stat_statements_reset();
+
-- SET statements.
-- These use two different strings, still they count as one entry.
SET work_mem = '1MB';