Skip to content

Commit 298f4e2

Browse files
committed
Merge PGPROEE9_6 into PGPRO-202_CFS_review_and_cleanup
2 parents 953f919 + 1c9bc72 commit 298f4e2

File tree

194 files changed

+14212
-1885
lines changed

Some content is hidden

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

194 files changed

+14212
-1885
lines changed

.ci/make_test_base

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ On success, starts database
99
"""
1010
import os,sys,subprocess,glob,re,os.path,time
1111

12-
datadir=sys.argv[1]
13-
14-
if not datadir:
15-
print >>sys.stderr,"Usage %s directory"%sys.argv[0]
12+
if len(sys.argv)!=2:
13+
print >>sys.stderr,"Usage %s data-directory" % sys.argv[0]
1614
sys.exit(1)
1715

16+
datadir=sys.argv[1]
17+
1818
if os.access(datadir,os.R_OK):
1919
import shutil
2020
shutil.rmtree(datadir)

.ci/run_install_check

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22
# Makes temporary installation and runs installcheck-world on it
33
# Should be run as non-privileged user.
44
# Exit on all errors
5+
# If run without arguments, makes installcheck-world
6+
# Otherwise first argument is interpreted as subdirectory
7+
# to change before runnning make installchedk
8+
# i.e
9+
# run_install_check .
10+
# test core only
11+
# run_install_check contrib
12+
# tests contrib only
13+
# etc.
14+
# All other arguments are passed to Makefile intact
15+
# To make possible pass arguments to installcheck-world
16+
# run_install_check world
17+
# does the same as no args
518
set -e
619
# Install
720
make install prefix=`pwd`/tmp_install
@@ -19,7 +32,13 @@ export PGPORT
1932
./.ci/make_test_base $PGDATA
2033
#run checks
2134
set +e
35+
if [ -z "$1" -o "$1" = "world" ]; then
2236
make installcheck-world prefix=`pwd`/tmp_install NO_LOCALE=1
37+
else
38+
dir=$1
39+
shift
40+
make -C "$dir" installcheck prefix=`pwd`/tmp_install NO_LOCALE=1 ${@:+"$@"}
41+
fi
2342
code=$?
2443
pg_ctl stop -D $PGDATA
2544
exit $code

COPYRIGHT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PostgreSQL Database Management System
22
(formerly known as Postgres, then as Postgres95)
33

4-
Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
4+
Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
55

66
Portions Copyright (c) 1994, The Regents of the University of California
77

configure

Lines changed: 108 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2754,7 +2754,7 @@ else
27542754
fi
27552755

27562756

2757-
PGPRO_VERSION="$PACKAGE_VERSION.2"
2757+
PGPRO_VERSION="$PACKAGE_VERSION.3"
27582758
PGPRO_PACKAGE_NAME="PostgresPro"
27592759
PGPRO_EDITION="enterprise"
27602760

@@ -9898,6 +9898,62 @@ done
98989898
fi
98999899

99009900
if test "$with_icu" = yes ; then
9901+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing ucol_open" >&5
9902+
$as_echo_n "checking for library containing ucol_open... " >&6; }
9903+
if ${ac_cv_search_ucol_open+:} false; then :
9904+
$as_echo_n "(cached) " >&6
9905+
else
9906+
ac_func_search_save_LIBS=$LIBS
9907+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
9908+
/* end confdefs.h. */
9909+
9910+
/* Override any GCC internal prototype to avoid an error.
9911+
Use char because int might match the return type of a GCC
9912+
builtin and then its argument prototype would still apply. */
9913+
#ifdef __cplusplus
9914+
extern "C"
9915+
#endif
9916+
char ucol_open ();
9917+
int
9918+
main ()
9919+
{
9920+
return ucol_open ();
9921+
;
9922+
return 0;
9923+
}
9924+
_ACEOF
9925+
for ac_lib in '' icui18n icuin; do
9926+
if test -z "$ac_lib"; then
9927+
ac_res="none required"
9928+
else
9929+
ac_res=-l$ac_lib
9930+
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
9931+
fi
9932+
if ac_fn_c_try_link "$LINENO"; then :
9933+
ac_cv_search_ucol_open=$ac_res
9934+
fi
9935+
rm -f core conftest.err conftest.$ac_objext \
9936+
conftest$ac_exeext
9937+
if ${ac_cv_search_ucol_open+:} false; then :
9938+
break
9939+
fi
9940+
done
9941+
if ${ac_cv_search_ucol_open+:} false; then :
9942+
9943+
else
9944+
ac_cv_search_ucol_open=no
9945+
fi
9946+
rm conftest.$ac_ext
9947+
LIBS=$ac_func_search_save_LIBS
9948+
fi
9949+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_ucol_open" >&5
9950+
$as_echo "$ac_cv_search_ucol_open" >&6; }
9951+
ac_res=$ac_cv_search_ucol_open
9952+
if test "$ac_res" != no; then :
9953+
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
9954+
9955+
else
9956+
99019957
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing ucol_open_57" >&5
99029958
$as_echo_n "checking for library containing ucol_open_57... " >&6; }
99039959
if ${ac_cv_search_ucol_open_57+:} false; then :
@@ -10900,6 +10956,54 @@ fi
1090010956

1090110957
fi
1090210958

10959+
10960+
fi
10961+
10962+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ucnv_fromUChars in -licuuc" >&5
10963+
$as_echo_n "checking for ucnv_fromUChars in -licuuc... " >&6; }
10964+
if ${ac_cv_lib_icuuc_ucnv_fromUChars+:} false; then :
10965+
$as_echo_n "(cached) " >&6
10966+
else
10967+
ac_check_lib_save_LIBS=$LIBS
10968+
LIBS="-licuuc $LIBS"
10969+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
10970+
/* end confdefs.h. */
10971+
10972+
/* Override any GCC internal prototype to avoid an error.
10973+
Use char because int might match the return type of a GCC
10974+
builtin and then its argument prototype would still apply. */
10975+
#ifdef __cplusplus
10976+
extern "C"
10977+
#endif
10978+
char ucnv_fromUChars ();
10979+
int
10980+
main ()
10981+
{
10982+
return ucnv_fromUChars ();
10983+
;
10984+
return 0;
10985+
}
10986+
_ACEOF
10987+
if ac_fn_c_try_link "$LINENO"; then :
10988+
ac_cv_lib_icuuc_ucnv_fromUChars=yes
10989+
else
10990+
ac_cv_lib_icuuc_ucnv_fromUChars=no
10991+
fi
10992+
rm -f core conftest.err conftest.$ac_objext \
10993+
conftest$ac_exeext conftest.$ac_ext
10994+
LIBS=$ac_check_lib_save_LIBS
10995+
fi
10996+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_icuuc_ucnv_fromUChars" >&5
10997+
$as_echo "$ac_cv_lib_icuuc_ucnv_fromUChars" >&6; }
10998+
if test "x$ac_cv_lib_icuuc_ucnv_fromUChars" = xyes; then :
10999+
cat >>confdefs.h <<_ACEOF
11000+
#define HAVE_LIBICUUC 1
11001+
_ACEOF
11002+
11003+
LIBS="-licuuc $LIBS"
11004+
11005+
else
11006+
1090311007
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ucnv_fromUChars_57 in -licuuc" >&5
1090411008
$as_echo_n "checking for ucnv_fromUChars_57 in -licuuc... " >&6; }
1090511009
if ${ac_cv_lib_icuuc_ucnv_fromUChars_57+:} false; then :
@@ -11713,6 +11817,9 @@ fi
1171311817
fi
1171411818

1171511819

11820+
fi
11821+
11822+
1171611823
fi
1171711824

1171811825
fi

configure.in

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ AC_DEFINE_UNQUOTED(PG_MAJORVERSION, "$PG_MAJORVERSION", [PostgreSQL major versio
3838
PGAC_ARG_REQ(with, extra-version, [STRING], [append STRING to version],
3939
[PG_VERSION="$PACKAGE_VERSION$withval"],
4040
[PG_VERSION="$PACKAGE_VERSION"])
41-
PGPRO_VERSION="$PACKAGE_VERSION.2"
41+
PGPRO_VERSION="$PACKAGE_VERSION.3"
4242
PGPRO_PACKAGE_NAME="PostgresPro"
4343
PGPRO_EDITION="enterprise"
4444
AC_SUBST(PGPRO_PACKAGE_NAME)
@@ -1162,6 +1162,7 @@ if test "$with_openssl" = yes ; then
11621162
fi
11631163

11641164
if test "$with_icu" = yes ; then
1165+
AC_SEARCH_LIBS(ucol_open, [icui18n icuin], [], [
11651166
AC_SEARCH_LIBS(ucol_open_57, [icui18n icuin], [], [
11661167
AC_SEARCH_LIBS(ucol_open_56, [icui18n icuin], [], [
11671168
AC_SEARCH_LIBS(ucol_open_55, [icui18n icuin], [], [
@@ -1195,6 +1196,8 @@ if test "$with_icu" = yes ; then
11951196
])
11961197
])
11971198
])
1199+
])
1200+
AC_CHECK_LIB(icuuc, ucnv_fromUChars, [], [
11981201
AC_CHECK_LIB(icuuc, ucnv_fromUChars_57, [], [
11991202
AC_CHECK_LIB(icuuc, ucnv_fromUChars_56, [], [
12001203
AC_CHECK_LIB(icuuc, ucnv_fromUChars_55, [], [
@@ -1228,6 +1231,7 @@ if test "$with_icu" = yes ; then
12281231
])
12291232
])
12301233
])
1234+
])
12311235
fi
12321236

12331237
if test "$with_pam" = yes ; then

contrib/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ SUBDIRS = \
88
adminpack \
99
auth_delay \
1010
auto_explain \
11+
aqo \
1112
bloom \
1213
btree_gin \
1314
btree_gist \

contrib/aqo/Makefile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# contrib/aqo/Makefile
2+
3+
EXTENSION = aqo
4+
PGFILEDESC = "AQO - adaptive query optimization"
5+
MODULES = aqo
6+
DATA = aqo--1.0.sql
7+
OBJS = aqo.o auto_tuning.o cardinality_estimation.o cardinality_hooks.o \
8+
hash.o machine_learning.o path_utils.o postprocessing.o preprocessing.o \
9+
selectivity_cache.o storage.o utils.o $(WIN32RES)
10+
REGRESS = aqo_disabled aqo_manual aqo_intelligent aqo_forced
11+
12+
MODULE_big = aqo
13+
ifdef USE_PGXS
14+
PG_CONFIG = pg_config
15+
PGXS := $(shell $(PG_CONFIG) --pgxs)
16+
include $(PGXS)
17+
else
18+
subdir = contrib/aqo
19+
top_builddir = ../..
20+
include $(top_builddir)/src/Makefile.global
21+
include $(top_srcdir)/contrib/contrib-global.mk
22+
endif

contrib/aqo/README.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Adaptive query optimization
2+
3+
Adaptive query optimization is the extension of standard PostgreSQL cost-based
4+
query optimizer. Its basic principle is to use query execution statistics
5+
for improving cardinality estimation. Experimental evaluation shows that this
6+
improvement sometimes provides an enormously large speed-up for rather
7+
complicated queries.
8+
9+
## Installation
10+
11+
In your db:
12+
CREATE EXTENSION aqo;
13+
14+
and modify your postgresql.conf:
15+
shared_preload_libraries = 'aqo.so'
16+
17+
It is essential that library is preloaded during server startup, because
18+
adaptive query optimization has to be enabled on per-database basis instead
19+
of per-connection.
20+
21+
## Usage
22+
23+
Note that the extension works bad with dynamically generated views. If they
24+
appear in workload, please use "aqo.mode='manual'".
25+
26+
This extension has intelligent self-tuning mode. If you want to rely completely
27+
on it, just add line "aqo.mode = 'intelligent'" into your postgresql.conf.
28+
29+
Now this mode may work not good for rapidly changing data and query
30+
distributions, so it is better to reset extension manually when that happens.
31+
32+
Also please note that intelligent mode is not supposed to work with queries
33+
with dynamically generated structure. Dynamically generated constants are okay.
34+
35+
For handling workloads with dynamically generated query structures the forced
36+
mode "aqo.mode = 'forced'" is provided. We cannot guarantee performance
37+
improvement with this mode, but you may try it nevertheless.
38+
39+
If you want to completely control how PostgreSQL optimizes queries, use manual
40+
mode "aqo.mode = 'manual'" and
41+
contrib/aqo/learn_queries.sh file_with_sql_queries.sql "psql -d YOUR_DATABASE"
42+
where file_with_sql_queries.sql is a textfile with queries on which AQO is
43+
supposed to learn. Please use only SELECT queries file_with_sql_queries.sql.
44+
More sophisticated and convenient tool for AQO administration is in the
45+
development now.
46+
If you want to freeze optimizer's behavior (i. e. disable learning under
47+
workload), use "UPDATE aqo_queries SET auto_tuning=false;".
48+
If you want to disable AQO for all queries, you may use
49+
"UPDATE aqo_queries SET use_aqo=false, learn_aqo=false, auto_tuning=false;".
50+
51+
## Advanced tuning
52+
53+
To control query optimization we introduce for each query its type.
54+
We consider that queries belong to the same type if and only if they differ only
55+
in their constants.
56+
One can see an example of query corresponding to the specified query type
57+
in table aqo_query_texts.
58+
select * from aqo_query_texts;
59+
60+
That is why intelligent mode does not work for dynamically generated query
61+
structures: it tries to learn separately how to optimize different query types,
62+
and for dynamical query structure the query types are different, so it will
63+
consume a lot of memory and will not optimize any query properly.
64+
65+
Forced mode forces AQO to ignore query types and optimize them together. On one
66+
hand it lacks of intelligent tuning, so the performance for some queries may
67+
even decrease, on the other hand it may work for dynamic workload and consumes
68+
less memory than the intelligent mode. That is why you may want to use it.
69+
70+
Each query type has its own optimization settings. You can find them in table
71+
aqo_queries.
72+
73+
Auto_tuning setting identifies whether AQO module tries to tune other settings
74+
from aqo_queries for the query type on its own. If the mode is intelligent,
75+
default value for new queries is true. If the mode is not intelligent, new queries
76+
are not appended to aqo_queries automatically, but you can also set auto_tuning
77+
variable to true manually.
78+
79+
Use_aqo setting shows whether AQO cardinalities prediction be used for next
80+
execution of such query type. Disabling of AQO usage is reasonable for that
81+
cases in which query execution time increases after applying AQO. It happens
82+
sometimes because of cost models incompleteness.
83+
84+
Learn_aqo setting shows whether AQO collects statistics for next execution of
85+
such query type. True value may have computational overheads, but it is
86+
essential when AQO model does not fit the data. It happens at the start of AQO
87+
for the new query type or when the data distribution in database is changed.
88+
89+
Fspace_hash setting is for extra advanced AQO tuning. It may be changed manually
90+
to optimize a number of query types using the same model. It may decrease the
91+
amount of memory for models and even query execution performance, but also it
92+
may cause the bad AQO's behavior, so please use it only if you know exactly
93+
what you do.
94+
95+
## Statistics
96+
97+
For forced and intelligent query modes, and for all tracked queries the
98+
statistics is collected. The statistics is cardinality quality, planning and
99+
execution time. For forced mode the statistics for all untracked query types
100+
is stored in common query type with hash 0.
101+
102+
One can see the collected statistics in table aqo_query_stat.

0 commit comments

Comments
 (0)