Skip to content

Commit 8f8db28

Browse files
committed
Additional service functions introduced
1 parent 8cf6290 commit 8f8db28

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

aqo--1.1--1.2.sql

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,43 @@ WHERE (aqs.query_hash = aq.query_hash) AND
6262
aqs.query_hash = $1;
6363
$func$ LANGUAGE SQL;
6464

65+
CREATE FUNCTION public.aqo_enable_query(hash int)
66+
RETURNS VOID
67+
AS $func$
68+
UPDATE aqo_queries SET
69+
learn_aqo = 'true',
70+
use_aqo = 'true'
71+
WHERE query_hash = $1;
72+
$func$ LANGUAGE SQL;
73+
74+
CREATE FUNCTION public.aqo_disable_query(hash int)
75+
RETURNS VOID
76+
AS $func$
77+
UPDATE aqo_queries SET
78+
learn_aqo = 'false',
79+
use_aqo = 'false',
80+
auto_tuning = 'false'
81+
WHERE query_hash = $1;
82+
$func$ LANGUAGE SQL;
83+
84+
CREATE FUNCTION public.aqo_clear_hist(hash int)
85+
RETURNS VOID
86+
AS $func$
87+
DELETE FROM aqo_data WHERE fspace_hash=$1;
88+
$func$ LANGUAGE SQL;
89+
6590
-- Show queries that contains 'Never executed' nodes at the plan.
6691
CREATE FUNCTION public.aqo_ne_queries()
6792
RETURNS SETOF int
6893
AS $func$
6994
SELECT query_hash FROM aqo_query_stat aqs WHERE -1 = ANY (cardinality_error_with_aqo::double precision[]);
7095
$func$ LANGUAGE SQL;
96+
97+
CREATE FUNCTION public.aqo_drop(hash int)
98+
RETURNS VOID
99+
AS $func$
100+
DELETE FROM aqo_queries aq WHERE (aq.query_hash = $1);
101+
DELETE FROM aqo_data ad WHERE (ad.fspace_hash = $1);
102+
DELETE FROM aqo_query_stat aq WHERE (aq.query_hash = $1);
103+
DELETE FROM aqo_query_texts aq WHERE (aq.query_hash = $1);
104+
$func$ LANGUAGE SQL;

0 commit comments

Comments
 (0)