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

Commitd0ff67f

Browse files
committed
Arrange stable13 with the stable14 code.
1 parentdf901da commitd0ff67f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+3812
-1536
lines changed

‎.github/workflows/c-cpp.yml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ jobs:
1212
runs-on:ubuntu-latest
1313

1414
steps:
15-
-name:Install additional packages
16-
run:sudo apt-get install -y libperl-dev libipc-run-perl
1715
-name:pg
1816
run:|
1917
echo "Deploying to production server on branch $GITHUB_REF"

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ regression.out
88
*.gcov
99
tags
1010

11+
# Generated subdirectories
12+
/log/
13+
/tmp_check/

‎Makefile‎

100644100755
Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,19 @@ REGRESS =aqo_disabled \
2020
aqo_CVE-2020-14350\
2121
gucs\
2222
forced_stat_collection\
23-
unsupported
23+
unsupported\
24+
clean_aqo_data\
25+
plancache\
26+
top_queries
2427

2528
fdw_srcdir =$(top_srcdir)/contrib/postgres_fdw
26-
PG_CPPFLAGS += -I$(libpq_srcdir) -I$(fdw_srcdir)
29+
stat_srcdir =$(top_srcdir)/contrib/pg_stat_statements
30+
PG_CPPFLAGS += -I$(libpq_srcdir) -I$(fdw_srcdir) -I$(stat_srcdir)
2731
EXTRA_REGRESS_OPTS=--temp-config=$(top_srcdir)/$(subdir)/conf.add
28-
EXTRA_CLEAN =$(pg_regress_clean_files) sql/tablespace.sql\
29-
sql/misc.sql sql/largeobject.sql sql/create_function_2.sql\
30-
sql/create_function_1.sql sql/copy.sql sql/constraints.sql\
31-
expected/tablespace.out\
32-
expected/misc.out expected/largeobject.out expected/largeobject_1.out\
33-
expected/create_function_2.out expected/create_function_1.out\
34-
expected/copy.out expected/copy_1.out expected/constraints.out
35-
EXTRA_INSTALL = contrib/postgres_fdw
32+
EXTRA_INSTALL = contrib/postgres_fdw contrib/pg_stat_statements
3633

37-
DATA = aqo--1.0.sql aqo--1.0--1.1.sql aqo--1.1--1.2.sql aqo--1.2.sql
34+
DATA = aqo--1.0.sql aqo--1.0--1.1.sql aqo--1.1--1.2.sql aqo--1.2.sql\
35+
aqo--1.2--1.3.sql
3836

3937
ifdefUSE_PGXS
4038
PG_CONFIG ?= pg_config
@@ -46,14 +44,3 @@ top_builddir = ../..
4644
include$(top_builddir)/src/Makefile.global
4745
include$(top_srcdir)/contrib/contrib-global.mk
4846
endif
49-
50-
aqo-regress:
51-
$(with_temp_install)\
52-
$(top_builddir)/src/test/regress/pg_regress \
53-
--temp-instance=./tmp_check\
54-
$(pg_regress_locale_flags)\
55-
--bindir=''\
56-
--dlpath=$(CURDIR)/$(top_builddir)/src/test/regress\
57-
--inputdir=$(abs_top_srcdir)/src/test/regress\
58-
--schedule=$(CURDIR)/schedule\
59-
--load-extension=aqo

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ Dynamically generated constants are okay.
325325

326326
##License
327327

328-
©[Postgres Professional](https://postgrespro.com/), 2016-2020. Licensed under
328+
©[Postgres Professional](https://postgrespro.com/), 2016-2021. Licensed under
329329
[The PostgreSQL License](LICENSE).
330330

331331
##Reference

‎aqo--1.0.sql‎

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

44
CREATETABLEpublic.aqo_queries (
5-
query_hashintPRIMARY KEY,
5+
query_hashbigintPRIMARY KEY,
66
learn_aqobooleanNOT NULL,
77
use_aqobooleanNOT NULL,
8-
fspace_hashintNOT NULL,
8+
fspace_hashbigintNOT NULL,
99
auto_tuningbooleanNOT NULL
1010
);
1111

1212
CREATETABLEpublic.aqo_query_texts (
13-
query_hashintPRIMARY KEYREFERENCESpublic.aqo_queriesON DELETE CASCADE,
13+
query_hashbigintPRIMARY KEYREFERENCESpublic.aqo_queriesON DELETE CASCADE,
1414
query_textvarcharNOT NULL
1515
);
1616

1717
CREATETABLEpublic.aqo_query_stat (
18-
query_hashintPRIMARY KEYREFERENCESpublic.aqo_queriesON DELETE CASCADE,
18+
query_hashbigintPRIMARY KEYREFERENCESpublic.aqo_queriesON DELETE CASCADE,
1919
execution_time_with_aqodouble precision[],
2020
execution_time_without_aqodouble precision[],
2121
planning_time_with_aqodouble precision[],
@@ -27,7 +27,7 @@ CREATE TABLE public.aqo_query_stat (
2727
);
2828

2929
CREATETABLEpublic.aqo_data (
30-
fspace_hashintNOT NULLREFERENCESpublic.aqo_queriesON DELETE CASCADE,
30+
fspace_hashbigintNOT NULLREFERENCESpublic.aqo_queriesON DELETE CASCADE,
3131
fsspace_hashintNOT NULL,
3232
nfeaturesintNOT NULL,
3333
featuresdouble precision[][],

‎aqo--1.1--1.2.sql‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ DROP FUNCTION aqo_migrate_to_1_2_get_pk(regclass);
2828
--
2929

3030
-- Show query state at the AQO knowledge base
31-
CREATE OR REPLACEFUNCTIONpublic.aqo_status(hashint)
31+
CREATE OR REPLACEFUNCTIONpublic.aqo_status(hashbigint)
3232
RETURNS TABLE (
3333
"learn"BOOL,
3434
"use aqo"BOOL,
3535
"auto tune"BOOL,
36-
"fspace hash"INT,
36+
"fspace hash"bigINT,
3737
"t_naqo"TEXT,
3838
"err_naqo"TEXT,
3939
"iters"BIGINT,
@@ -63,7 +63,7 @@ WHERE (aqs.query_hash = aq.query_hash) AND
6363
aqs.query_hash= $1;
6464
$func$ LANGUAGE SQL;
6565

66-
CREATE OR REPLACEFUNCTIONpublic.aqo_enable_query(hashint)
66+
CREATE OR REPLACEFUNCTIONpublic.aqo_enable_query(hashbigint)
6767
RETURNS VOID
6868
AS $func$
6969
UPDATEpublic.aqo_queriesSET
@@ -72,7 +72,7 @@ UPDATE public.aqo_queries SET
7272
WHERE query_hash= $1;
7373
$func$ LANGUAGE SQL;
7474

75-
CREATE OR REPLACEFUNCTIONpublic.aqo_disable_query(hashint)
75+
CREATE OR REPLACEFUNCTIONpublic.aqo_disable_query(hashbigint)
7676
RETURNS VOID
7777
AS $func$
7878
UPDATEpublic.aqo_queriesSET
@@ -82,7 +82,7 @@ UPDATE public.aqo_queries SET
8282
WHERE query_hash= $1;
8383
$func$ LANGUAGE SQL;
8484

85-
CREATE OR REPLACEFUNCTIONpublic.aqo_clear_hist(hashint)
85+
CREATE OR REPLACEFUNCTIONpublic.aqo_clear_hist(hashbigint)
8686
RETURNS VOID
8787
AS $func$
8888
DELETEFROMpublic.aqo_dataWHERE fspace_hash=$1;
@@ -96,7 +96,7 @@ SELECT query_hash FROM public.aqo_query_stat aqs
9696
WHERE-1= ANY (cardinality_error_with_aqo::double precision[]);
9797
$func$ LANGUAGE SQL;
9898

99-
CREATE OR REPLACEFUNCTIONpublic.aqo_drop(hashint)
99+
CREATE OR REPLACEFUNCTIONpublic.aqo_drop(hashbigint)
100100
RETURNS VOID
101101
AS $func$
102102
DELETEFROMpublic.aqo_queries aqWHERE (aq.query_hash= $1);

‎aqo--1.2--1.3.sql‎

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
ALTERTABLEpublic.aqo_data ADD COLUMN oidsOID [] DEFAULTNULL;
2+
3+
--
4+
-- Remove data, related to previously dropped tables, from the AQO tables.
5+
--
6+
CREATE OR REPLACEFUNCTIONpublic.clean_aqo_data() RETURNS voidAS $$
7+
DECLARE
8+
aqo_data_row aqo_data%ROWTYPE;
9+
aqo_queries_row aqo_queries%ROWTYPE;
10+
aqo_query_texts_row aqo_query_texts%ROWTYPE;
11+
aqo_query_stat_row aqo_query_stat%ROWTYPE;
12+
oid_varoid;
13+
fspace_hash_varbigint;
14+
delete_rowboolean DEFAULT false;
15+
BEGIN
16+
RAISE NOTICE'Cleaning aqo_data records';
17+
18+
FOR aqo_data_rowIN (SELECT*FROM aqo_data)
19+
LOOP
20+
delete_row= false;
21+
SELECTaqo_data_row.fspace_hash INTO fspace_hash_varFROM aqo_data;
22+
23+
IF (aqo_data_row.oidsIS NOT NULL) THEN
24+
FOREACH oid_varIN ARRAYaqo_data_row.oids
25+
LOOP
26+
IF NOT EXISTS (SELECT relnameFROM pg_classWHEREoid= oid_var) THEN
27+
delete_row= true;
28+
END IF;
29+
END LOOP;
30+
END IF;
31+
32+
FOR aqo_queries_rowIN (SELECT*FROM aqo_queries)
33+
LOOP
34+
IF (delete_row= trueAND fspace_hash_var<>0AND
35+
fspace_hash_var=aqo_queries_row.fspace_hashAND
36+
aqo_queries_row.fspace_hash=aqo_queries_row.query_hash) THEN
37+
DELETEFROM aqo_dataWHERE aqo_data= aqo_data_row;
38+
DELETEFROM aqo_queriesWHERE aqo_queries= aqo_queries_row;
39+
40+
FOR aqo_query_texts_rowIN (SELECT*FROM aqo_query_texts)
41+
LOOP
42+
DELETEFROM aqo_query_texts
43+
WHEREaqo_query_texts_row.query_hash= fspace_hash_varAND
44+
aqo_query_texts= aqo_query_texts_row;
45+
END LOOP;
46+
47+
FOR aqo_query_stat_rowIN (SELECT*FROM aqo_query_stat)
48+
LOOP
49+
DELETEFROM aqo_query_stat
50+
WHEREaqo_query_stat_row.query_hash= fspace_hash_varAND
51+
aqo_query_stat= aqo_query_stat_row;
52+
END LOOP;
53+
END IF;
54+
END LOOP;
55+
END LOOP;
56+
END;
57+
$$ LANGUAGE plpgsql;
58+
59+
CREATE OR REPLACEFUNCTIONarray_avg(arrdouble precision[]) RETURNSdouble precisionas $$
60+
BEGIN
61+
RETURN (SELECTAVG(a)FROM UNNEST(arr)AS a);
62+
END;
63+
$$ LANGUAGE plpgsql;
64+
65+
CREATE OR REPLACEFUNCTIONarray_mse(arrdouble precision[]) RETURNSdouble precisionas $$
66+
DECLARE
67+
meandouble precision;
68+
BEGIN
69+
mean= array_avg(arr);
70+
RETURN (SELECTAVG(POWER(a- mean,2))FROM UNNEST(arr)AS a);
71+
END;
72+
$$ LANGUAGE plpgsql;
73+
74+
75+
--
76+
-- Show top N of 'bad' queries.
77+
--
78+
-- The AQO extension must be installed, but disabled.
79+
-- Strictly speaking, these functions shows 'query classes' that includes all
80+
-- queries of the same structure. An query example of a class can be found in the
81+
-- aqo_query_texts table.
82+
-- This functions can be used to gentle search of 'bad' queries. User must set:
83+
-- aqo.mode = 'disabled'
84+
-- aqo.force_collect_stat = 'on'
85+
--
86+
87+
--
88+
-- Top of queries with the highest value of execution time.
89+
--
90+
CREATE OR REPLACEFUNCTIONpublic.top_time_queries(nint)
91+
RETURNS TABLE(numbigint,
92+
fspace_hashbigint,
93+
query_hashbigint,
94+
execution_time float,
95+
deviation float
96+
)
97+
AS $$
98+
BEGIN
99+
RAISE NOTICE'Top % execution time queries', n;
100+
RETURN QUERY
101+
SELECT row_number() OVER(ORDER BY execution_time_without_aqoDESC) num,
102+
aqo_queries.fspace_hash,
103+
aqo_queries.query_hash,
104+
to_char(array_avg(execution_time_without_aqo),'9.99EEEE')::float,
105+
to_char(array_mse(execution_time_without_aqo),'9.99EEEE')::float
106+
FROM aqo_queriesINNER JOIN aqo_query_stat
107+
ONaqo_queries.query_hash=aqo_query_stat.query_hash
108+
GROUP BY (execution_time_without_aqo,aqo_queries.fspace_hash,aqo_queries.query_hash)
109+
ORDER BY execution_timeDESCLIMIT n;
110+
END;
111+
$$ LANGUAGE plpgsql;
112+
113+
--
114+
-- Top of queries with largest value of total cardinality error.
115+
--
116+
CREATE OR REPLACEFUNCTIONpublic.top_error_queries(nint)
117+
RETURNS TABLE(numbigint,
118+
fspace_hashbigint,
119+
query_hashbigint,
120+
error float,
121+
deviation float
122+
)
123+
AS $$
124+
BEGIN
125+
RAISE NOTICE'Top % cardinality error queries', n;
126+
RETURN QUERY
127+
SELECT row_number() OVER (ORDER BY cardinality_error_without_aqoDESC) num,
128+
aqo_queries.fspace_hash,
129+
aqo_queries.query_hash,
130+
to_char(array_avg(cardinality_error_without_aqo),'9.99EEEE')::float,
131+
to_char(array_mse(cardinality_error_without_aqo),'9.99EEEE')::float
132+
FROM aqo_queriesINNER JOIN aqo_query_stat
133+
ONaqo_queries.query_hash=aqo_query_stat.query_hash
134+
GROUP BY (cardinality_error_without_aqo,aqo_queries.fspace_hash,aqo_queries.query_hash)
135+
ORDER BY errorDESCLIMIT n;
136+
END;
137+
$$ LANGUAGE plpgsql;
138+

‎aqo--1.2.sql‎

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

44
CREATETABLEpublic.aqo_queries (
5-
query_hashintCONSTRAINT aqo_queries_query_hash_idxPRIMARY KEY,
5+
query_hashbigintCONSTRAINT aqo_queries_query_hash_idxPRIMARY KEY,
66
learn_aqobooleanNOT NULL,
77
use_aqobooleanNOT NULL,
8-
fspace_hashintNOT NULL,
8+
fspace_hashbigintNOT NULL,
99
auto_tuningbooleanNOT NULL
1010
);
1111

1212
CREATETABLEpublic.aqo_query_texts (
13-
query_hashintCONSTRAINT aqo_query_texts_query_hash_idxPRIMARY KEYREFERENCESpublic.aqo_queriesON DELETE CASCADE,
13+
query_hashbigintCONSTRAINT aqo_query_texts_query_hash_idxPRIMARY KEYREFERENCESpublic.aqo_queriesON DELETE CASCADE,
1414
query_texttextNOT NULL
1515
);
1616

1717
CREATETABLEpublic.aqo_query_stat (
18-
query_hashintCONSTRAINT aqo_query_stat_idxPRIMARY KEYREFERENCESpublic.aqo_queriesON DELETE CASCADE,
18+
query_hashbigintCONSTRAINT aqo_query_stat_idxPRIMARY KEYREFERENCESpublic.aqo_queriesON DELETE CASCADE,
1919
execution_time_with_aqodouble precision[],
2020
execution_time_without_aqodouble precision[],
2121
planning_time_with_aqodouble precision[],
@@ -27,7 +27,7 @@ CREATE TABLE public.aqo_query_stat (
2727
);
2828

2929
CREATETABLEpublic.aqo_data (
30-
fspace_hashintNOT NULLREFERENCESpublic.aqo_queriesON DELETE CASCADE,
30+
fspace_hashbigintNOT NULLREFERENCESpublic.aqo_queriesON DELETE CASCADE,
3131
fsspace_hashintNOT NULL,
3232
nfeaturesintNOT NULL,
3333
featuresdouble precision[][],
@@ -52,12 +52,12 @@ CREATE TRIGGER aqo_queries_invalidate AFTER UPDATE OR DELETE OR TRUNCATE
5252
--
5353

5454
-- Show query state at the AQO knowledge base
55-
CREATEFUNCTIONpublic.aqo_status(hashint)
55+
CREATEFUNCTIONpublic.aqo_status(hashbigint)
5656
RETURNS TABLE (
5757
"learn"BOOL,
5858
"use aqo"BOOL,
5959
"auto tune"BOOL,
60-
"fspace hash"INT,
60+
"fspace hash"bigINT,
6161
"t_naqo"TEXT,
6262
"err_naqo"TEXT,
6363
"iters"BIGINT,
@@ -87,7 +87,7 @@ WHERE (aqs.query_hash = aq.query_hash) AND
8787
aqs.query_hash= $1;
8888
$func$ LANGUAGE SQL;
8989

90-
CREATEFUNCTIONpublic.aqo_enable_query(hashint)
90+
CREATEFUNCTIONpublic.aqo_enable_query(hashbigint)
9191
RETURNS VOID
9292
AS $func$
9393
UPDATEpublic.aqo_queriesSET
@@ -96,7 +96,7 @@ UPDATE public.aqo_queries SET
9696
WHERE query_hash= $1;
9797
$func$ LANGUAGE SQL;
9898

99-
CREATEFUNCTIONpublic.aqo_disable_query(hashint)
99+
CREATEFUNCTIONpublic.aqo_disable_query(hashbigint)
100100
RETURNS VOID
101101
AS $func$
102102
UPDATEpublic.aqo_queriesSET
@@ -106,7 +106,7 @@ UPDATE public.aqo_queries SET
106106
WHERE query_hash= $1;
107107
$func$ LANGUAGE SQL;
108108

109-
CREATEFUNCTIONpublic.aqo_clear_hist(hashint)
109+
CREATEFUNCTIONpublic.aqo_clear_hist(hashbigint)
110110
RETURNS VOID
111111
AS $func$
112112
DELETEFROMpublic.aqo_dataWHERE fspace_hash=$1;
@@ -120,7 +120,7 @@ SELECT query_hash FROM public.aqo_query_stat aqs
120120
WHERE-1= ANY (cardinality_error_with_aqo::double precision[]);
121121
$func$ LANGUAGE SQL;
122122

123-
CREATEFUNCTIONpublic.aqo_drop(hashint)
123+
CREATEFUNCTIONpublic.aqo_drop(hashbigint)
124124
RETURNS VOID
125125
AS $func$
126126
DELETEFROMpublic.aqo_queries aqWHERE (aq.query_hash= $1);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp