Skip to content

Commit 2f4ce3c

Browse files
svglukhovdanolivo
authored andcommitted
Added functions:
aqo_query_texts_update(), aqo_query_stat_update(), aqo_data_update(). Changed function to be able to insert a record: aqo_queries_update().
1 parent eb1f545 commit 2f4ce3c

12 files changed

+1127
-55
lines changed

aqo--1.5--1.6.sql

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,50 @@ AS 'MODULE_PATHNAME', 'aqo_cleanup'
3030
LANGUAGE C STRICT VOLATILE;
3131
COMMENT ON FUNCTION aqo_cleanup() IS
3232
'Remove unneeded rows from the AQO ML storage';
33+
34+
--
35+
-- Update or insert an aqo_query_texts
36+
-- table record for given 'queryid'.
37+
--
38+
39+
CREATE FUNCTION aqo_query_texts_update(
40+
queryid bigint, query_text text)
41+
RETURNS bool
42+
AS 'MODULE_PATHNAME', 'aqo_query_texts_update'
43+
LANGUAGE C VOLATILE;
44+
45+
--
46+
-- Update or insert an aqo_query_stat
47+
-- table record for given 'queryid'.
48+
--
49+
50+
CREATE FUNCTION aqo_query_stat_update(
51+
queryid bigint,
52+
execution_time_with_aqo double precision[],
53+
execution_time_without_aqo double precision[],
54+
planning_time_with_aqo double precision[],
55+
planning_time_without_aqo double precision[],
56+
cardinality_error_with_aqo double precision[],
57+
cardinality_error_without_aqo double precision[],
58+
executions_with_aqo bigint,
59+
executions_without_aqo bigint)
60+
RETURNS bool
61+
AS 'MODULE_PATHNAME', 'aqo_query_stat_update'
62+
LANGUAGE C VOLATILE;
63+
64+
--
65+
-- Update or insert an aqo_data
66+
-- table record for given 'fs' & 'fss'.
67+
--
68+
69+
CREATE FUNCTION aqo_data_update(
70+
fs bigint,
71+
fss integer,
72+
nfeatures integer,
73+
features double precision[][],
74+
targets double precision[],
75+
reliability double precision[],
76+
oids Oid[])
77+
RETURNS bool
78+
AS 'MODULE_PATHNAME', 'aqo_data_update'
79+
LANGUAGE C VOLATILE;

auto_tuning.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,10 @@ automatical_query_tuning(uint64 queryid, StatEntry *stat)
202202

203203
if (num_iterations <= auto_tuning_max_iterations || p_use > 0.5)
204204
aqo_queries_store(queryid, query_context.fspace_hash,
205-
query_context.learn_aqo, query_context.use_aqo, true);
205+
query_context.learn_aqo, query_context.use_aqo, true,
206+
&aqo_queries_nulls);
206207
else
207208
aqo_queries_store(queryid,
208-
query_context.fspace_hash, false, false, false);
209+
query_context.fspace_hash, false, false, false,
210+
&aqo_queries_nulls);
209211
}

expected/plancache.out

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,10 @@ SELECT * FROM f1();
4444

4545
DROP FUNCTION f1;
4646
DROP TABLE test CASCADE;
47+
SELECT true FROM aqo_reset();
48+
bool
49+
------
50+
t
51+
(1 row)
52+
4753
DROP EXTENSION aqo;

0 commit comments

Comments
 (0)