Test local cached queries & prepared statements

pull/6763/head
Gokhan Gulbiz 2023-03-23 11:51:09 +03:00
parent 931554fb32
commit 0efb897706
No known key found for this signature in database
GPG Key ID: 608EF06B6BD1B45B
2 changed files with 267 additions and 0 deletions

View File

@ -383,6 +383,7 @@ SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, q
(6 rows)
\c - - - :worker_2_port
SET search_path TO citus_stats_tenants;
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stats_tenants ORDER BY tenant_attribute;
tenant_attribute | read_count_in_this_period | read_count_in_last_period | query_count_in_this_period | query_count_in_last_period
---------------------------------------------------------------------
@ -392,6 +393,216 @@ SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, q
bcde* | 1 | 0 | 1 | 0
(4 rows)
SELECT result FROM run_command_on_all_nodes('SELECT clean_citus_stats_tenants()');
result
---------------------------------------------------------------------
(2 rows)
-- test local queries
SELECT count(*)>=0 FROM dist_tbl_text WHERE a = '/b*c/de';
?column?
---------------------------------------------------------------------
t
(1 row)
SELECT count(*)>=0 FROM dist_tbl_text WHERE a = '/bcde';
?column?
---------------------------------------------------------------------
t
(1 row)
SELECT count(*)>=0 FROM dist_tbl_text WHERE a = U&'\0061\0308bc';
?column?
---------------------------------------------------------------------
t
(1 row)
SELECT count(*)>=0 FROM dist_tbl_text WHERE a = 'bcde*';
?column?
---------------------------------------------------------------------
t
(1 row)
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stats_tenants ORDER BY tenant_attribute;
tenant_attribute | read_count_in_this_period | read_count_in_last_period | query_count_in_this_period | query_count_in_last_period
---------------------------------------------------------------------
/b*c/de | 1 | 0 | 1 | 0
/bcde | 1 | 0 | 1 | 0
äbc | 1 | 0 | 1 | 0
bcde* | 1 | 0 | 1 | 0
(4 rows)
-- test local cached queries & prepared statements
PREPARE dist_tbl_text_select_plan (text) AS SELECT count(*)>=0 FROM dist_tbl_text WHERE a = $1;
EXECUTE dist_tbl_text_select_plan('/b*c/de');
?column?
---------------------------------------------------------------------
t
(1 row)
EXECUTE dist_tbl_text_select_plan('/bcde');
?column?
---------------------------------------------------------------------
t
(1 row)
EXECUTE dist_tbl_text_select_plan(U&'\0061\0308bc');
?column?
---------------------------------------------------------------------
t
(1 row)
EXECUTE dist_tbl_text_select_plan('bcde*');
?column?
---------------------------------------------------------------------
t
(1 row)
EXECUTE dist_tbl_text_select_plan('/b*c/de');
?column?
---------------------------------------------------------------------
t
(1 row)
EXECUTE dist_tbl_text_select_plan('/bcde');
?column?
---------------------------------------------------------------------
t
(1 row)
EXECUTE dist_tbl_text_select_plan(U&'\0061\0308bc');
?column?
---------------------------------------------------------------------
t
(1 row)
EXECUTE dist_tbl_text_select_plan('bcde*');
?column?
---------------------------------------------------------------------
t
(1 row)
EXECUTE dist_tbl_text_select_plan('/b*c/de');
?column?
---------------------------------------------------------------------
t
(1 row)
EXECUTE dist_tbl_text_select_plan('/bcde');
?column?
---------------------------------------------------------------------
t
(1 row)
EXECUTE dist_tbl_text_select_plan(U&'\0061\0308bc');
?column?
---------------------------------------------------------------------
t
(1 row)
EXECUTE dist_tbl_text_select_plan('bcde*');
?column?
---------------------------------------------------------------------
t
(1 row)
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stats_tenants ORDER BY tenant_attribute;
tenant_attribute | read_count_in_this_period | read_count_in_last_period | query_count_in_this_period | query_count_in_last_period
---------------------------------------------------------------------
/b*c/de | 4 | 0 | 4 | 0
/bcde | 4 | 0 | 4 | 0
äbc | 4 | 0 | 4 | 0
bcde* | 4 | 0 | 4 | 0
(4 rows)
\c - - - :master_port
SET search_path TO citus_stats_tenants;
PREPARE dist_tbl_text_select_plan (text) AS SELECT count(*)>=0 FROM dist_tbl_text WHERE a = $1;
EXECUTE dist_tbl_text_select_plan('/b*c/de');
?column?
---------------------------------------------------------------------
t
(1 row)
EXECUTE dist_tbl_text_select_plan('/bcde');
?column?
---------------------------------------------------------------------
t
(1 row)
EXECUTE dist_tbl_text_select_plan(U&'\0061\0308bc');
?column?
---------------------------------------------------------------------
t
(1 row)
EXECUTE dist_tbl_text_select_plan('bcde*');
?column?
---------------------------------------------------------------------
t
(1 row)
EXECUTE dist_tbl_text_select_plan('/b*c/de');
?column?
---------------------------------------------------------------------
t
(1 row)
EXECUTE dist_tbl_text_select_plan('/bcde');
?column?
---------------------------------------------------------------------
t
(1 row)
EXECUTE dist_tbl_text_select_plan(U&'\0061\0308bc');
?column?
---------------------------------------------------------------------
t
(1 row)
EXECUTE dist_tbl_text_select_plan('bcde*');
?column?
---------------------------------------------------------------------
t
(1 row)
EXECUTE dist_tbl_text_select_plan('/b*c/de');
?column?
---------------------------------------------------------------------
t
(1 row)
EXECUTE dist_tbl_text_select_plan('/bcde');
?column?
---------------------------------------------------------------------
t
(1 row)
EXECUTE dist_tbl_text_select_plan(U&'\0061\0308bc');
?column?
---------------------------------------------------------------------
t
(1 row)
EXECUTE dist_tbl_text_select_plan('bcde*');
?column?
---------------------------------------------------------------------
t
(1 row)
\c - - - :worker_2_port
SET search_path TO citus_stats_tenants;
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stats_tenants ORDER BY tenant_attribute;
tenant_attribute | read_count_in_this_period | read_count_in_last_period | query_count_in_this_period | query_count_in_last_period
---------------------------------------------------------------------
/b*c/de | 7 | 0 | 7 | 0
/bcde | 7 | 0 | 7 | 0
äbc | 7 | 0 | 7 | 0
bcde* | 7 | 0 | 7 | 0
(4 rows)
\c - - - :master_port
SET client_min_messages TO ERROR;
DROP SCHEMA citus_stats_tenants CASCADE;

View File

@ -128,7 +128,63 @@ SELECT count(*)>=0 FROM dist_tbl_text WHERE a = U&'\0061\0308bc';
\c - - - :worker_1_port
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stats_tenants ORDER BY tenant_attribute;
\c - - - :worker_2_port
SET search_path TO citus_stats_tenants;
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stats_tenants ORDER BY tenant_attribute;
SELECT result FROM run_command_on_all_nodes('SELECT clean_citus_stats_tenants()');
-- test local queries
SELECT count(*)>=0 FROM dist_tbl_text WHERE a = '/b*c/de';
SELECT count(*)>=0 FROM dist_tbl_text WHERE a = '/bcde';
SELECT count(*)>=0 FROM dist_tbl_text WHERE a = U&'\0061\0308bc';
SELECT count(*)>=0 FROM dist_tbl_text WHERE a = 'bcde*';
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stats_tenants ORDER BY tenant_attribute;
-- test local cached queries & prepared statements
PREPARE dist_tbl_text_select_plan (text) AS SELECT count(*)>=0 FROM dist_tbl_text WHERE a = $1;
EXECUTE dist_tbl_text_select_plan('/b*c/de');
EXECUTE dist_tbl_text_select_plan('/bcde');
EXECUTE dist_tbl_text_select_plan(U&'\0061\0308bc');
EXECUTE dist_tbl_text_select_plan('bcde*');
EXECUTE dist_tbl_text_select_plan('/b*c/de');
EXECUTE dist_tbl_text_select_plan('/bcde');
EXECUTE dist_tbl_text_select_plan(U&'\0061\0308bc');
EXECUTE dist_tbl_text_select_plan('bcde*');
EXECUTE dist_tbl_text_select_plan('/b*c/de');
EXECUTE dist_tbl_text_select_plan('/bcde');
EXECUTE dist_tbl_text_select_plan(U&'\0061\0308bc');
EXECUTE dist_tbl_text_select_plan('bcde*');
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stats_tenants ORDER BY tenant_attribute;
\c - - - :master_port
SET search_path TO citus_stats_tenants;
PREPARE dist_tbl_text_select_plan (text) AS SELECT count(*)>=0 FROM dist_tbl_text WHERE a = $1;
EXECUTE dist_tbl_text_select_plan('/b*c/de');
EXECUTE dist_tbl_text_select_plan('/bcde');
EXECUTE dist_tbl_text_select_plan(U&'\0061\0308bc');
EXECUTE dist_tbl_text_select_plan('bcde*');
EXECUTE dist_tbl_text_select_plan('/b*c/de');
EXECUTE dist_tbl_text_select_plan('/bcde');
EXECUTE dist_tbl_text_select_plan(U&'\0061\0308bc');
EXECUTE dist_tbl_text_select_plan('bcde*');
EXECUTE dist_tbl_text_select_plan('/b*c/de');
EXECUTE dist_tbl_text_select_plan('/bcde');
EXECUTE dist_tbl_text_select_plan(U&'\0061\0308bc');
EXECUTE dist_tbl_text_select_plan('bcde*');
\c - - - :worker_2_port
SET search_path TO citus_stats_tenants;
SELECT tenant_attribute, read_count_in_this_period, read_count_in_last_period, query_count_in_this_period, query_count_in_last_period FROM citus_stats_tenants ORDER BY tenant_attribute;
\c - - - :master_port
SET client_min_messages TO ERROR;