Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1c42ba9

Browse files
funbringerdanolivo
authored andcommitted
provide solid upgrade to 1.1
1 parent6aafe3a commit1c42ba9

File tree

5 files changed

+97
-36
lines changed

5 files changed

+97
-36
lines changed

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ regression.out
77
*.gcno
88
*.gcov
99
tags
10+
11+
aqo--?.?.sql

‎Makefile‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
# contrib/aqo/Makefile
22

33
EXTENSION = aqo
4+
EXTVERSION = 1.1
45
PGFILEDESC = "AQO - adaptive query optimization"
56
MODULES = aqo
6-
DATA = aqo--1.0.sql
77
OBJS = aqo.o auto_tuning.o cardinality_estimation.o cardinality_hooks.o\
88
hash.o machine_learning.o path_utils.o postprocessing.o preprocessing.o\
99
selectivity_cache.o storage.o utils.o$(WIN32RES)
1010

1111
REGRESS = aqo_disabled aqo_controlled aqo_intelligent aqo_forced aqo_learn
12-
EXTRA_REGRESS_OPTS=--temp-config=$(CURDIR)/conf.add
12+
EXTRA_REGRESS_OPTS=--temp-config=$(top_srcdir)/$(subdir)/conf.add
13+
14+
DATA = aqo--1.0.sql aqo--1.0--1.1.sql
15+
DATA_built = aqo--$(EXTVERSION).sql
1316

1417
MODULE_big = aqo
1518
ifdefUSE_PGXS
@@ -22,3 +25,7 @@ top_builddir = ../..
2225
include$(top_builddir)/src/Makefile.global
2326
include$(top_srcdir)/contrib/contrib-global.mk
2427
endif
28+
29+
30+
$(DATA_built):$(DATA)
31+
cat$(DATA)>$(DATA_built)

‎aqo--1.0--1.1.sql‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
ALTERTABLE aqo_query_texts ALTER COLUMN query_text TYPEtext;
2+
3+
4+
DROPINDEX aqo_query_texts_query_hash_idx CASCADE;
5+
DROPINDEX aqo_queries_query_hash_idx CASCADE;
6+
DROPINDEX aqo_query_stat_idx CASCADE;
7+
DROPINDEX aqo_fss_access_idx CASCADE;
8+
9+
CREATEUNIQUE INDEXaqo_fss_access_idxON aqo_data (fspace_hash, fsspace_hash);
10+
11+
12+
CREATE OR REPLACEFUNCTIONaqo_migrate_to_1_1_get_pk(rel regclass) RETURNS regclassAS $$
13+
DECLARE
14+
idx regclass;
15+
BEGIN
16+
SELECTi.indexrelidFROMpg_catalog.pg_index iJOIN
17+
pg_catalog.pg_attribute aONa.attrelid=i.indrelidAND
18+
a.attnum= ANY(i.indkey)
19+
WHEREi.indrelid= relAND
20+
i.indisprimary
21+
INTO idx;
22+
23+
RETURN idx;
24+
END
25+
$$ LANGUAGE plpgsql;
26+
27+
28+
DO $$
29+
BEGIN
30+
EXECUTE format('ALTER TABLE %s RENAME to %s',
31+
aqo_migrate_to_1_1_get_pk('aqo_queries'),
32+
'aqo_queries_query_hash_idx');
33+
34+
EXECUTE format('ALTER TABLE %s RENAME to %s',
35+
aqo_migrate_to_1_1_get_pk('aqo_query_texts'),
36+
'aqo_query_texts_query_hash_idx');
37+
38+
EXECUTE format('ALTER TABLE %s RENAME to %s',
39+
aqo_migrate_to_1_1_get_pk('aqo_query_stat'),
40+
'aqo_query_stat_idx');
41+
END
42+
$$;
43+
44+
45+
DROPFUNCTION aqo_migrate_to_1_1_get_pk(regclass);

‎aqo--1.0.sql‎

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,58 @@
22
\echo Use"CREATE EXTENSION aqo" to load this file. \quit
33

44
CREATETABLEaqo_queries (
5-
query_hashint4CONSTRAINT"aqo_queries_query_hash_idx"
6-
PRIMARY KEY,
7-
learn_aqoboolNOT NULL,
8-
use_aqoboolNOT NULL,
9-
fspace_hashint4NOT NULL,
10-
auto_tuningboolNOT NULL
5+
query_hashintPRIMARY KEY,
6+
learn_aqobooleanNOT NULL,
7+
use_aqobooleanNOT NULL,
8+
fspace_hashintNOT NULL,
9+
auto_tuningbooleanNOT NULL
1110
);
1211

1312
CREATETABLEaqo_query_texts (
14-
query_hashint4CONSTRAINT"aqo_query_texts_query_hash_idx"
15-
PRIMARY KEYREFERENCES aqo_queriesON DELETE CASCADE,
16-
query_texttextNOT NULL
13+
query_hashintPRIMARY KEYREFERENCES aqo_queriesON DELETE CASCADE,
14+
query_textvarcharNOT NULL
1715
);
1816

1917
CREATETABLEaqo_query_stat (
20-
query_hashint4CONSTRAINT"aqo_query_stat_idx"
21-
PRIMARY KEYREFERENCES aqo_queriesON DELETE CASCADE,
22-
execution_time_with_aqofloat8[],
23-
execution_time_without_aqofloat8[],
24-
planning_time_with_aqofloat8[],
25-
planning_time_without_aqofloat8[],
26-
cardinality_error_with_aqofloat8[],
27-
cardinality_error_without_aqofloat8[],
28-
executions_with_aqoint8,
29-
executions_without_aqoint8
18+
query_hashintPRIMARY KEYREFERENCES aqo_queriesON DELETE CASCADE,
19+
execution_time_with_aqodouble precision[],
20+
execution_time_without_aqodouble precision[],
21+
planning_time_with_aqodouble precision[],
22+
planning_time_without_aqodouble precision[],
23+
cardinality_error_with_aqodouble precision[],
24+
cardinality_error_without_aqodouble precision[],
25+
executions_with_aqobigint,
26+
executions_without_aqobigint
3027
);
3128

3229
CREATETABLEaqo_data (
33-
fspace_hashint4NOT NULLREFERENCES aqo_queriesON DELETE CASCADE,
34-
fsspace_hashint4NOT NULL,
35-
nfeaturesint4NOT NULL,
36-
featuresfloat8[][],
37-
targetsfloat8[]
30+
fspace_hashintNOT NULLREFERENCES aqo_queriesON DELETE CASCADE,
31+
fsspace_hashintNOT NULL,
32+
nfeaturesintNOT NULL,
33+
featuresdouble precision[][],
34+
targetsdouble precision[],
35+
UNIQUE (fspace_hash, fsspace_hash)
3836
);
3937

40-
CREATEUNIQUE INDEXaqo_fss_access_idxON aqo_data (fspace_hash, fsspace_hash);
38+
CREATEINDEXaqo_queries_query_hash_idxON aqo_queries (query_hash);
39+
CREATEINDEXaqo_query_texts_query_hash_idxON aqo_query_texts (query_hash);
40+
CREATEINDEXaqo_query_stat_idxON aqo_query_stat (query_hash);
41+
CREATEINDEXaqo_fss_access_idxON aqo_data (fspace_hash, fsspace_hash);
4142

42-
ALTERTABLE aqo_dataALTER COLUMN featuresSET STORAGE MAIN;
43-
ALTERTABLE aqo_dataALTER COLUMN targetsSET STORAGE MAIN;
44-
ALTERTABLE aqo_query_statALTER COLUMN execution_time_with_aqoSET STORAGE MAIN;
45-
ALTERTABLE aqo_query_statALTER COLUMN execution_time_without_aqoSET STORAGE MAIN;
46-
ALTERTABLE aqo_query_statALTER COLUMN planning_time_with_aqoSET STORAGE MAIN;
47-
ALTERTABLE aqo_query_statALTER COLUMN planning_time_without_aqoSET STORAGE MAIN;
48-
ALTERTABLE aqo_query_statALTER COLUMN cardinality_error_without_aqoSET STORAGE MAIN;
49-
ALTERTABLE aqo_query_statALTER COLUMN cardinality_error_with_aqoSET STORAGE MAIN;
43+
ALTERTABLE aqo_data ALTER COLUMN featuresSET STORAGE MAIN;
44+
ALTERTABLE aqo_data ALTER COLUMN targetsSET STORAGE MAIN;
45+
ALTERTABLE aqo_query_stat
46+
ALTER COLUMN execution_time_with_aqoSET STORAGE MAIN;
47+
ALTERTABLE aqo_query_stat
48+
ALTER COLUMN execution_time_without_aqoSET STORAGE MAIN;
49+
ALTERTABLE aqo_query_stat
50+
ALTER COLUMN planning_time_with_aqoSET STORAGE MAIN;
51+
ALTERTABLE aqo_query_stat
52+
ALTER COLUMN planning_time_without_aqoSET STORAGE MAIN;
53+
ALTERTABLE aqo_query_stat
54+
ALTER COLUMN cardinality_error_without_aqoSET STORAGE MAIN;
55+
ALTERTABLE aqo_query_stat
56+
ALTER COLUMN cardinality_error_with_aqoSET STORAGE MAIN;
5057

5158
INSERT INTO aqo_queriesVALUES (0, false, false,0, false);
5259
INSERT INTO aqo_query_textsVALUES (0,'COMMON feature space (do not delete!)');

‎aqo.control‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# AQO extension
22
comment = 'machine learning for cardinality estimation in optimizer'
3-
default_version = '1.0'
3+
default_version = '1.1'
44
module_pathname = '$libdir/aqo'
55
relocatable = false

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp