-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add query denormalization regression test for prepared statements
Ensures that the denormalization of prepared statements is working, also ensure that a query which takes more time to execute replaces the previous denormalized query.
- Loading branch information
1 parent
548dd61
commit 2487f44
Showing
3 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
CREATE EXTENSION pg_stat_monitor; | ||
Set pg_stat_monitor.pgsm_normalized_query='off'; | ||
CREATE TABLE t1 (a TEXT, b TEXT, c TEXT); | ||
SELECT pg_stat_monitor_reset(); | ||
pg_stat_monitor_reset | ||
----------------------- | ||
|
||
(1 row) | ||
|
||
PREPARE prepstmt(TEXT, TEXT, TEXT) AS INSERT INTO t1(a, b, c) VALUES($1, $2, $3); | ||
EXECUTE prepstmt('A', 'B', 'C'); | ||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C"; | ||
query | calls | ||
--------------------------------------------------------------------------------+------- | ||
PREPARE prepstmt(TEXT, TEXT, TEXT) AS INSERT INTO t1(a, b, c) VALUES(A, B, C); | 1 | ||
SELECT pg_stat_monitor_reset() | 1 | ||
(2 rows) | ||
|
||
EXECUTE prepstmt(REPEAT('XYZ', 8192), md5(random()::text), REPEAT('RANDOM', 4096)); | ||
SELECT SUBSTRING(query, 0, 128), calls FROM pg_stat_monitor ORDER BY query COLLATE "C"; | ||
substring | calls | ||
---------------------------------------------------------------------------------------------------------------------------------+------- | ||
PREPARE prepstmt(TEXT, TEXT, TEXT) AS INSERT INTO t1(a, b, c) VALUES(XYZXYZXYZXYZXYZXYZXYZXYZXYZXYZXYZXYZXYZXYZXYZXYZXYZXYZXYZX | 2 | ||
SELECT pg_stat_monitor_reset() | 1 | ||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C" | 1 | ||
(3 rows) | ||
|
||
DROP TABLE t1; | ||
SELECT pg_stat_monitor_reset(); | ||
pg_stat_monitor_reset | ||
----------------------- | ||
|
||
(1 row) | ||
|
||
DROP EXTENSION pg_stat_monitor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
CREATE EXTENSION pg_stat_monitor; | ||
Set pg_stat_monitor.pgsm_normalized_query='off'; | ||
|
||
CREATE TABLE t1 (a TEXT, b TEXT, c TEXT); | ||
|
||
SELECT pg_stat_monitor_reset(); | ||
|
||
PREPARE prepstmt(TEXT, TEXT, TEXT) AS INSERT INTO t1(a, b, c) VALUES($1, $2, $3); | ||
|
||
EXECUTE prepstmt('A', 'B', 'C'); | ||
SELECT query, calls FROM pg_stat_monitor ORDER BY query COLLATE "C"; | ||
|
||
EXECUTE prepstmt(REPEAT('XYZ', 8192), md5(random()::text), REPEAT('RANDOM', 4096)); | ||
SELECT SUBSTRING(query, 0, 128), calls FROM pg_stat_monitor ORDER BY query COLLATE "C"; | ||
|
||
DROP TABLE t1; | ||
|
||
SELECT pg_stat_monitor_reset(); | ||
DROP EXTENSION pg_stat_monitor; |