1
1
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
2
2
\echo Use " CREATE EXTENSION aqo" to load this file. \quit
3
3
4
- CREATE TABLE aqo_queries (
4
+ CREATE TABLE public . aqo_queries (
5
5
query_hash bigint CONSTRAINT aqo_queries_query_hash_idx PRIMARY KEY ,
6
6
learn_aqo boolean NOT NULL ,
7
7
use_aqo boolean NOT NULL ,
8
8
fspace_hash bigint NOT NULL ,
9
9
auto_tuning boolean NOT NULL
10
10
);
11
11
12
- CREATE TABLE aqo_query_texts (
13
- query_hash bigint CONSTRAINT aqo_query_texts_query_hash_idx PRIMARY KEY REFERENCES aqo_queries ON DELETE CASCADE ,
12
+ CREATE TABLE public . aqo_query_texts (
13
+ query_hash bigint CONSTRAINT aqo_query_texts_query_hash_idx PRIMARY KEY REFERENCES public . aqo_queries ON DELETE CASCADE ,
14
14
query_text text NOT NULL
15
15
);
16
16
17
- CREATE TABLE aqo_query_stat (
18
- query_hash bigint CONSTRAINT aqo_query_stat_idx PRIMARY KEY REFERENCES aqo_queries ON DELETE CASCADE ,
17
+ CREATE TABLE public . aqo_query_stat (
18
+ query_hash bigint CONSTRAINT aqo_query_stat_idx PRIMARY KEY REFERENCES public . aqo_queries ON DELETE CASCADE ,
19
19
execution_time_with_aqo double precision [],
20
20
execution_time_without_aqo double precision [],
21
21
planning_time_with_aqo double precision [],
@@ -26,33 +26,33 @@ CREATE TABLE aqo_query_stat (
26
26
executions_without_aqo bigint
27
27
);
28
28
29
- CREATE TABLE aqo_data (
30
- fspace_hash bigint NOT NULL REFERENCES aqo_queries ON DELETE CASCADE ,
29
+ CREATE TABLE public . aqo_data (
30
+ fspace_hash bigint NOT NULL REFERENCES public . aqo_queries ON DELETE CASCADE ,
31
31
fsspace_hash int NOT NULL ,
32
32
nfeatures int NOT NULL ,
33
33
features double precision [][],
34
34
targets double precision []
35
35
);
36
36
37
- CREATE UNIQUE INDEX aqo_fss_access_idx ON aqo_data (fspace_hash, fsspace_hash);
37
+ CREATE UNIQUE INDEX aqo_fss_access_idx ON public . aqo_data (fspace_hash, fsspace_hash);
38
38
39
- INSERT INTO aqo_queries VALUES (0 , false, false, 0 , false);
40
- INSERT INTO aqo_query_texts VALUES (0 , ' COMMON feature space (do not delete!)' );
39
+ INSERT INTO public . aqo_queries VALUES (0 , false, false, 0 , false);
40
+ INSERT INTO public . aqo_query_texts VALUES (0 , ' COMMON feature space (do not delete!)' );
41
41
-- a virtual query for COMMON feature space
42
42
43
43
CREATE FUNCTION invalidate_deactivated_queries_cache () RETURNS trigger
44
44
AS ' MODULE_PATHNAME' LANGUAGE C;
45
45
46
46
CREATE TRIGGER aqo_queries_invalidate AFTER UPDATE OR DELETE OR TRUNCATE
47
- ON aqo_queries FOR EACH STATEMENT
47
+ ON public . aqo_queries FOR EACH STATEMENT
48
48
EXECUTE PROCEDURE invalidate_deactivated_queries_cache();
49
49
50
50
--
51
51
-- Service functions
52
52
--
53
53
54
54
-- Show query state at the AQO knowledge base
55
- CREATE FUNCTION aqo_status (hash bigint )
55
+ CREATE FUNCTION public . aqo_status(hash bigint )
56
56
RETURNS TABLE (
57
57
" learn" BOOL,
58
58
" use aqo" BOOL,
@@ -73,58 +73,58 @@ SELECT learn_aqo,use_aqo,auto_tuning,fspace_hash,
73
73
to_char(execution_time_with_aqo[n3],' 9.99EEEE' ),
74
74
to_char(cardinality_error_with_aqo[n1],' 9.99EEEE' ),
75
75
executions_with_aqo
76
- FROM aqo_queries aq, aqo_query_stat aqs,
76
+ FROM public . aqo_queries aq, public . aqo_query_stat aqs,
77
77
(SELECT array_length(n1,1 ) AS n1, array_length(n2,1 ) AS n2,
78
78
array_length(n3,1 ) AS n3, array_length(n4,1 ) AS n4
79
79
FROM
80
80
(SELECT cardinality_error_with_aqo AS n1,
81
81
cardinality_error_without_aqo AS n2,
82
82
execution_time_with_aqo AS n3,
83
83
execution_time_without_aqo AS n4
84
- FROM aqo_query_stat aqs WHERE
84
+ FROM public . aqo_query_stat aqs WHERE
85
85
aqs .query_hash = $1 ) AS al) AS q
86
86
WHERE (aqs .query_hash = aq .query_hash ) AND
87
87
aqs .query_hash = $1 ;
88
88
$func$ LANGUAGE SQL;
89
89
90
- CREATE FUNCTION aqo_enable_query (hash bigint )
90
+ CREATE FUNCTION public . aqo_enable_query(hash bigint )
91
91
RETURNS VOID
92
92
AS $func$
93
- UPDATE aqo_queries SET
93
+ UPDATE public . aqo_queries SET
94
94
learn_aqo = ' true' ,
95
95
use_aqo = ' true'
96
96
WHERE query_hash = $1 ;
97
97
$func$ LANGUAGE SQL;
98
98
99
- CREATE FUNCTION aqo_disable_query (hash bigint )
99
+ CREATE FUNCTION public . aqo_disable_query(hash bigint )
100
100
RETURNS VOID
101
101
AS $func$
102
- UPDATE aqo_queries SET
102
+ UPDATE public . aqo_queries SET
103
103
learn_aqo = ' false' ,
104
104
use_aqo = ' false' ,
105
105
auto_tuning = ' false'
106
106
WHERE query_hash = $1 ;
107
107
$func$ LANGUAGE SQL;
108
108
109
- CREATE FUNCTION aqo_clear_hist (hash bigint )
109
+ CREATE FUNCTION public . aqo_clear_hist(hash bigint )
110
110
RETURNS VOID
111
111
AS $func$
112
- DELETE FROM aqo_data WHERE fspace_hash= $1 ;
112
+ DELETE FROM public . aqo_data WHERE fspace_hash= $1 ;
113
113
$func$ LANGUAGE SQL;
114
114
115
115
-- Show queries that contains 'Never executed' nodes at the plan.
116
- CREATE FUNCTION aqo_ne_queries ()
116
+ CREATE FUNCTION public . aqo_ne_queries()
117
117
RETURNS SETOF int
118
118
AS $func$
119
- SELECT query_hash FROM aqo_query_stat aqs
119
+ SELECT query_hash FROM public . aqo_query_stat aqs
120
120
WHERE - 1 = ANY (cardinality_error_with_aqo::double precision []);
121
121
$func$ LANGUAGE SQL;
122
122
123
- CREATE FUNCTION aqo_drop (hash bigint )
123
+ CREATE FUNCTION public . aqo_drop(hash bigint )
124
124
RETURNS VOID
125
125
AS $func$
126
- DELETE FROM aqo_queries aq WHERE (aq .query_hash = $1 );
127
- DELETE FROM aqo_data ad WHERE (ad .fspace_hash = $1 );
128
- DELETE FROM aqo_query_stat aq WHERE (aq .query_hash = $1 );
129
- DELETE FROM aqo_query_texts aq WHERE (aq .query_hash = $1 );
126
+ DELETE FROM public . aqo_queries aq WHERE (aq .query_hash = $1 );
127
+ DELETE FROM public . aqo_data ad WHERE (ad .fspace_hash = $1 );
128
+ DELETE FROM public . aqo_query_stat aq WHERE (aq .query_hash = $1 );
129
+ DELETE FROM public . aqo_query_texts aq WHERE (aq .query_hash = $1 );
130
130
$func$ LANGUAGE SQL;
0 commit comments