Skip to content

Commit 21c755b

Browse files
author
Oleg Ivanov
committed
Style, typo, copyright, README and comment fixes
1 parent 8b62a8e commit 21c755b

File tree

14 files changed

+163
-163
lines changed

14 files changed

+163
-163
lines changed

contrib/aqo/README.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Adaptive query optimization
22

33
Adaptive query optimization is the extension of standard PostgreSQL cost-based
4-
query optimizer. Its basical principle is to use query execution statistics
4+
query optimizer. Its basic principle is to use query execution statistics
55
for improving cardinality estimation. Experimental evaluation shows that this
6-
improvement sometimes provides an enourmously large speed-up for rather
6+
improvement sometimes provides an enormously large speed-up for rather
77
complicated queries.
88

99
## Installation
@@ -36,16 +36,16 @@ For handling workloads with dynamically generated query structures the forced
3636
mode "aqo.mode = 'forced'" is provided. We cannot guarantee performance
3737
improvement with this mode, but you may try it nevertheless.
3838

39-
If you want to completelly control how PostgreSQL optimizes queries, use manual
39+
If you want to completely control how PostgreSQL optimizes queries, use manual
4040
mode "aqo.mode = 'manual'" and
4141
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
42+
where file_with_sql_queries.sql is a textfile with queries on which AQO is
4343
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
44+
More sophisticated and convenient tool for AQO administration is in the
4545
development now.
46-
If you want to freeze optimizer's behaviour (i. e. disable learning under
46+
If you want to freeze optimizer's behavior (i. e. disable learning under
4747
workload), use "UPDATE aqo_queries SET auto_tuning=false;".
48-
If you want to disable aqo for all queries, you may use
48+
If you want to disable AQO for all queries, you may use
4949
"UPDATE aqo_queries SET use_aqo=false, learn_aqo=false, auto_tuning=false;".
5050

5151
## Advanced tuning
@@ -62,34 +62,34 @@ structures: it tries to learn separately how to optimize different query types,
6262
and for dynamical query structure the query types are different, so it will
6363
consume a lot of memory and will not optimize any query properly.
6464

65-
Forced mode forces aqo to ignore query types and optimize them together. On one
65+
Forced mode forces AQO to ignore query types and optimize them together. On one
6666
hand it lacks of intelligent tuning, so the performance for some queries may
6767
even decrease, on the other hand it may work for dynamic workload and consumes
68-
less memory than the intellignet mode. That is why you may want to use it.
68+
less memory than the intelligent mode. That is why you may want to use it.
6969

7070
Each query type has its own optimization settings. You can find them in table
7171
aqo_queries.
7272

73-
Auto_tuning setting identifies whether aqo module tries to tune other settings
74-
from aqo_queries for the query type. If the mode is intelligent, defalt value
75-
for new queries is true. If the mode is not intelligent, new queries are not
76-
appended to aqo_queries automatically, but you can also set auto_tuning variable
77-
to true manually.
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.
7878

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
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
8282
sometimes because of cost models incompleteness.
8383

84-
Learn_aqo setting shows whether aqo collects statistics for next execution of
84+
Learn_aqo setting shows whether AQO collects statistics for next execution of
8585
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
86+
essential when AQO model does not fit the data. It happens at the start of AQO
8787
for the new query type or when the data distribution in database is changed.
8888

89-
Fspace_hash setting is for extra advanced aqo tuning. It may be changed manually
89+
Fspace_hash setting is for extra advanced AQO tuning. It may be changed manually
9090
to optimize a number of query types using the same model. It may decrease the
9191
amount of memory for models and even query execution performance, but also it
92-
may cause the bad aqo's behaviour, so please use it only if you know exactly
92+
may cause the bad AQO's behavior, so please use it only if you know exactly
9393
what you do.
9494

9595
## Statistics

contrib/aqo/aqo.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ _PG_fini(void)
120120

121121
PG_FUNCTION_INFO_V1(invalidate_deactivated_queries_cache);
122122

123+
/*
124+
* Clears the cache of deactivated queries if the user changed aqo_queries
125+
* manually.
126+
*/
123127
Datum
124128
invalidate_deactivated_queries_cache(PG_FUNCTION_ARGS)
125129
{

contrib/aqo/aqo.control

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

contrib/aqo/aqo.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* the execution statistics from previously executed queries is used.
77
* Adaptive query optimization extends standard PostgreSQL cost-based query
88
* optimization model.
9-
* This extension uses machine learning model builded over the collected
9+
* This extension uses machine learning model built over the collected
1010
* statistics to improve cardinality estimations.
1111
*
1212
* The extension organized as follows.
@@ -27,29 +27,29 @@
2727
* Feature spaces are described by their hashes (an integer value).
2828
*
2929
* This extension presents three default modes:
30-
* "intelligent" mode tries to automatically tune aqo settings for the current
30+
* "intelligent" mode tries to automatically tune AQO settings for the current
3131
* workload. It creates separate feature space for each new type of query
3232
* and then tries to improve the performance of such query type execution.
33-
* The automatical tuning may be manually deactivated for the given queries.
34-
* "forced" mode makes no difference between query types and use aqo for them
33+
* The automatic tuning may be manually deactivated for the given queries.
34+
* "forced" mode makes no difference between query types and use AQO for them
3535
* all in the similar way. It considers each new query type as linked to special
3636
* feature space called COMMON with hash 0.
37-
* "manual" mode ignores unknown query types. In this case aqo is completelly
38-
* configured manuallt by user.
37+
* "manual" mode ignores unknown query types. In this case AQO is completely
38+
* configured manually by user.
3939
* Current mode is stored in aqo.mode variable.
4040
*
4141
* User can manually set up his own feature space configuration
4242
* for query types by changing settings in table aqo_queries.
4343
*
4444
* Module preprocessing.c determines how to handle the given query.
45-
* This includes following questions: whether to use aqo for this query,
45+
* This includes following questions: whether to use AQO for this query,
4646
* whether to use execution statistics of this query to update machine
4747
* learning models, to what feature space the query belongs to, and whether
4848
* this query allows using intelligence autotuning for three previous questions.
4949
* This data is stored in aqo_queries table. Also this module links
5050
* new query types to their feature spaces according to aqo.mode.
5151
*
52-
* If it is supposed to use aqo for given type of query, the extension hooks
52+
* If it is supposed to use AQO for given type of query, the extension hooks
5353
* cardinality estimation functions in PostgreSQL. If the necessary statistics
5454
* for cardinality predictions using machine learning method is available,
5555
* the extension performs the prediction and returns its value. Otherwise it
@@ -59,12 +59,12 @@
5959
* for this part of work.
6060
*
6161
* If it is supposed to use execution statistics of given query for learning
62-
* models in aqo, the extension sets flag before execution to collect rows
62+
* models in AQO, the extension sets flag before execution to collect rows
6363
* statistics. After query execution the collected statistics is proceed in
6464
* the extension and the update of related feature space models is performed.
6565
* Module postprocessing.c is responsible for this part of work.
6666
* Also it saves query execution time and cardinality qualities of queries
67-
* for further analisys by aqo and DBA.
67+
* for further analysis by AQO and DBA.
6868
*
6969
* Note that extension is transaction-dependent. That means that user has to
7070
* commit transaction to make model updates visible for all backends.
@@ -101,7 +101,7 @@
101101
* Module storage.c is responsible for storage query settings and models
102102
* (i. e. all information which is used in extension).
103103
*
104-
* Copyright (c) 2016-2016, Postgres Professional
104+
* Copyright (c) 2016-2017, Postgres Professional
105105
*
106106
* IDENTIFICATION
107107
* contrib/aqo/aqo.h
@@ -270,7 +270,7 @@ double aqo_get_parameterized_joinrel_size(PlannerInfo *root,
270270
SpecialJoinInfo *sjinfo,
271271
List *restrict_clauses);
272272

273-
/* Extracting path infromation utilities */
273+
/* Extracting path information utilities */
274274
List *get_selectivities(PlannerInfo *root,
275275
List *clauses,
276276
int varRelid,
@@ -284,7 +284,7 @@ double predict_for_relation(List *restrict_clauses,
284284
List *selectivities,
285285
List *relids);
286286

287-
/* Query execution statictics collecting hooks */
287+
/* Query execution statistics collecting hooks */
288288
void aqo_ExecutorStart(QueryDesc *queryDesc, int eflags);
289289
void aqo_copy_generic_path_info(PlannerInfo *root, Plan *dest, Path *src);
290290
void learn_query_stat(QueryDesc *queryDesc);
@@ -297,7 +297,7 @@ List *OkNNr_learn(int matrix_rows, int matrix_cols,
297297
double **matrix, double *targets,
298298
double *nw_features, double nw_target);
299299

300-
/* Automatical query tuning */
300+
/* Automatic query tuning */
301301
void automatical_query_tuning(int query_hash, QueryStat * stat);
302302

303303
/* Utilities */

contrib/aqo/auto_tuning.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
/*****************************************************************************
44
*
5-
* AUTOMATICAL QUERY TUNING
5+
* AUTOMATIC QUERY TUNING
66
*
7-
* This module automatically implements basic strategies of tuning aqo for best
7+
* This module automatically implements basic strategies of tuning AQO for best
88
* PostgreSQL performance.
99
*
1010
*****************************************************************************/
@@ -44,7 +44,7 @@ converged_cq(double *elems, int nelems)
4444

4545
est = get_estimation(elems, nelems - 1);
4646
return (est * 1.1 > elems[nelems - 1] || est + 0.1 > elems[nelems - 1]) &&
47-
(est * 0.9 < elems[nelems - 1] || est - 0.1 < elems[nelems - 1]);
47+
(est * 0.9 < elems[nelems - 1] || est - 0.1 < elems[nelems - 1]);
4848
}
4949

5050
/*
@@ -55,26 +55,26 @@ converged_cq(double *elems, int nelems)
5555
* Now the workflow is quite simlple:
5656
*
5757
* Firstly, we run a new query type auto_tuning_window_size times without our
58-
* method to have an execution time statistics for such type of quieries.
59-
* Secondly, we run the query type with both aqo usage and aqo learning enabled
58+
* method to have an execution time statistics for such type of queries.
59+
* Secondly, we run the query type with both AQO usage and AQO learning enabled
6060
* until convergence.
6161
*
62-
* If aqo provides better execution time for the query type according to
62+
* If AQO provides better execution time for the query type according to
6363
* collected statistics, we prefer to enable it, otherwise we prefer to disable
6464
* it.
6565
* In the stable workload case we perform an exploration. That means that with
66-
* some probability which depends on execution time with and without using aqo
66+
* some probability which depends on execution time with and without using AQO
6767
* we run the slower method to check whether it remains slower.
6868
* Cardinality statistics collection is enabled by default in this mode.
6969
* If we find out that cardinality quality diverged during the exploration, we
70-
* return to step 2 and run the query type with both aqo usage and aqo learning
70+
* return to step 2 and run the query type with both AQO usage and AQO learning
7171
* enabled until convergence.
7272
* If after auto_tuning_max_iterations steps we consider that for this query
73-
* it is better not to use aqo, we set auto_tuning, learn_aqo and use_aqo for
73+
* it is better not to use AQO, we set auto_tuning, learn_aqo and use_aqo for
7474
* this query to false.
7575
*/
7676
void
77-
automatical_query_tuning(int query_hash, QueryStat *stat)
77+
automatical_query_tuning(int query_hash, QueryStat * stat)
7878
{
7979
double unstability = auto_tuning_exploration;
8080
double t_aqo,
@@ -93,12 +93,12 @@ automatical_query_tuning(int query_hash, QueryStat *stat)
9393
{
9494
t_aqo = get_estimation(stat->execution_time_with_aqo,
9595
stat->execution_time_with_aqo_size) +
96-
get_estimation(stat->planning_time_with_aqo,
97-
stat->planning_time_with_aqo_size);
96+
get_estimation(stat->planning_time_with_aqo,
97+
stat->planning_time_with_aqo_size);
9898
t_not_aqo = get_estimation(stat->execution_time_without_aqo,
9999
stat->execution_time_without_aqo_size) +
100-
get_estimation(stat->planning_time_without_aqo,
101-
stat->planning_time_without_aqo_size);
100+
get_estimation(stat->planning_time_without_aqo,
101+
stat->planning_time_without_aqo_size);
102102
p_use = t_not_aqo / (t_not_aqo + t_aqo);
103103
p_use = 1 / (1 + exp((p_use - 0.5) / unstability));
104104
p_use -= 1 / (1 + exp(-0.5 / unstability));

contrib/aqo/cardinality_hooks.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
*
77
* This functions controls cardinality prediction in query optimization.
88
* If use_aqo flag is false, then hooks just call default postgresql
9-
* cardinality estimator. Otherwise, they try to use aqo cardinality
9+
* cardinality estimator. Otherwise, they try to use AQO cardinality
1010
* prediction engine.
1111
* If use_aqo flag in true, hooks generate set of all clauses and all
12-
* absolute relids used in the relation beeing builded and pass this
12+
* absolute relids used in the relation being built and pass this
1313
* information to predict_for_relation function. Also these hooks compute
1414
* and pass to predict_for_relation marginal cardinalities for clauses.
15-
* If predict_for_relation returns non-negavite value, then hooks assume it
15+
* If predict_for_relation returns non-negative value, then hooks assume it
1616
* to be true cardinality for given relation. Negative returned value means
1717
* refusal to predict cardinality. In this case hooks also use default
18-
* postgresql cardinality estimator.
18+
* postgreSQL cardinality estimator.
1919
*
2020
*****************************************************************************/
2121

contrib/aqo/hash.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ get_id_in_sorted_int_array(int val, int n, int *arr)
364364

365365
/*
366366
* Returns class of equivalence for given argument hash or 0 if such hash
367-
* doen't belong to any equivalence class.
367+
* does not belong to any equivalence class.
368368
*/
369369
int
370370
get_arg_eclass(int arg_hash, int nargs, int *args_hash, int *eclass_hash)
@@ -499,7 +499,7 @@ perform_eclasses_join(List *clauselist, int nargs, int *args_hash)
499499
}
500500

501501
/*
502-
* Constructs arg_hashes and arg_hash->eclass_hash maping for all non-constant
502+
* Constructs arg_hashes and arg_hash->eclass_hash mapping for all non-constant
503503
* arguments of equivalence clauses of given clauselist.
504504
*/
505505
void
@@ -565,7 +565,7 @@ has_consts(List *lst)
565565
/*
566566
* Returns pointer on the args list in clause or NULL.
567567
*/
568-
List **
568+
List **
569569
get_clause_args_ptr(Expr *clause)
570570
{
571571
switch (clause->type)

contrib/aqo/machine_learning.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
*
55
* MACHINE LEARNING TECHNIQUES
66
*
7-
* This module doesn't know anything about DBMS, cardinalities and all other
8-
* stuff. It learns matrixes, predicts values and is quite happy.
7+
* This module does not know anything about DBMS, cardinalities and all other
8+
* stuff. It learns matrices, predicts values and is quite happy.
99
* The proposed method is designed for working with limited number of objects.
1010
* It is guaranteed that number of rows in the matrix will not exceed aqo_K
1111
* setting after learning procedure. This property also allows to adapt to

0 commit comments

Comments
 (0)