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

Commit80b803c

Browse files
committed
Merge branch 'PGPROEE9_6_aqo' into PGPROEE9_6
2 parents3cacdf4 +330a60f commit80b803c

14 files changed

+47
-36
lines changed

‎contrib/aqo/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ 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)
10-
REGRESS = aqo_disabledaqo_manual aqo_intelligent aqo_forced
10+
REGRESS = aqo_disabledaqo_controlled aqo_intelligent aqo_forced
1111

1212
MODULE_big = aqo
1313
ifdefUSE_PGXS

‎contrib/aqo/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ of per-connection.
2121
##Usage
2222

2323
Note that the extension works bad with dynamically generated views. If they
24-
appear in workload, please use "aqo.mode='manual'".
24+
appear in workload, please use "aqo.mode='controlled'".
2525

2626
This extension has intelligent self-tuning mode. If you want to rely completely
2727
on it, just add line "aqo.mode = 'intelligent'" into your postgresql.conf.
@@ -36,8 +36,8 @@ 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 completely control how PostgreSQL optimizes queries, usemanual
40-
mode "aqo.mode = 'manual'" and
39+
If you want to completely control how PostgreSQL optimizes queries, usecontrolled
40+
mode "aqo.mode = 'controlled'" and
4141
contrib/aqo/learn_queries.sh file_with_sql_queries.sql "psql -d YOUR_DATABASE"
4242
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.

‎contrib/aqo/aqo.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ intaqo_mode;
1212
staticconststructconfig_enum_entryformat_options[]= {
1313
{"intelligent",AQO_MODE_INTELLIGENT, false},
1414
{"forced",AQO_MODE_FORCED, false},
15-
{"manual",AQO_MODE_MANUAL, false},
15+
{"controlled",AQO_MODE_CONTROLLED, false},
1616
{"disabled",AQO_MODE_DISABLED, false},
1717
{NULL,0, false}
1818
};
@@ -74,7 +74,7 @@ _PG_init(void)
7474
"Mode of aqo usage.",
7575
NULL,
7676
&aqo_mode,
77-
AQO_MODE_MANUAL,
77+
AQO_MODE_CONTROLLED,
7878
format_options,
7979
PGC_SUSET,
8080
0,

‎contrib/aqo/aqo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* "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 completely
37+
* "Controlled" mode ignores unknown query types. In this case AQO is completely
3838
* configured manually by user.
3939
* Current mode is stored in aqo.mode variable.
4040
*
@@ -148,7 +148,7 @@ typedef enum
148148
/* Treats new query types as linked to the common feature space */
149149
AQO_MODE_FORCED,
150150
/* New query types are not linked with any feature space */
151-
AQO_MODE_MANUAL,
151+
AQO_MODE_CONTROLLED,
152152
/* Aqo is disabled for all queries */
153153
AQO_MODE_DISABLED,
154154
}AQO_MODE;

‎contrib/aqo/expected/aqo_manual.outrenamed to‎contrib/aqo/expected/aqo_controlled.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ AS (
2626
CREATE INDEX aqo_test2_idx_a ON aqo_test2 (a);
2727
ANALYZE aqo_test2;
2828
CREATE EXTENSION aqo;
29-
SET aqo.mode = 'manual';
29+
SET aqo.mode = 'controlled';
3030
EXPLAIN (COSTS FALSE)
3131
SELECT * FROM aqo_test0
3232
WHERE a < 3 AND b < 3 AND c < 3 AND d < 3;
@@ -105,7 +105,7 @@ SELECT count(*) FROM tmp1;
105105
(1 row)
106106

107107
DROP TABLE tmp1;
108-
SET aqo.mode = 'manual';
108+
SET aqo.mode = 'controlled';
109109
UPDATE aqo_queries SET auto_tuning=false;
110110
UPDATE aqo_queries SET learn_aqo=true;
111111
UPDATE aqo_queries SET use_aqo=false;

‎contrib/aqo/expected/aqo_disabled.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ SELECT count(*) FROM tmp1;
8383
(1 row)
8484

8585
DROP TABLE tmp1;
86-
SET aqo.mode = 'manual';
86+
SET aqo.mode = 'controlled';
8787
UPDATE aqo_queries SET learn_aqo = true, use_aqo = true, auto_tuning = false;
8888
EXPLAIN SELECT * FROM aqo_test0
8989
WHERE a < 3 AND b < 3 AND c < 3 AND d < 3;

‎contrib/aqo/expected/aqo_forced.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ AS (
1717
CREATE INDEX aqo_test1_idx_a ON aqo_test1 (a);
1818
ANALYZE aqo_test1;
1919
CREATE EXTENSION aqo;
20-
SET aqo.mode = 'manual';
20+
SET aqo.mode = 'controlled';
2121
EXPLAIN (COSTS FALSE)
2222
SELECT * FROM aqo_test0
2323
WHERE a < 3 AND b < 3 AND c < 3 AND d < 3;

‎contrib/aqo/expected/aqo_intelligent.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ SELECT count(*) FROM tmp1;
296296
(1 row)
297297

298298
DROP TABLE tmp1;
299-
SET aqo.mode = 'manual';
299+
SET aqo.mode = 'controlled';
300300
UPDATE aqo_queries SET learn_aqo = false, use_aqo = false, auto_tuning = false;
301301
EXPLAIN SELECT * FROM aqo_test0
302302
WHERE a < 3 AND b < 3 AND c < 3 AND d < 3;

‎contrib/aqo/preprocessing.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*typing strategy by changing hash function.
2727
* 2. New query type proceeding. The handling policy for new query types is
2828
*contained in variable 'aqo.mode'. It accepts three values:
29-
*"intelligent", "forced", and "manual".
29+
*"intelligent", "forced","controlled"and "disabled".
3030
*Intelligent linking strategy means that for each new query type the new
3131
*separate feature space is created. The hash of new feature space is
3232
*set the same as the hash of new query type. Auto tuning is on by
@@ -35,10 +35,11 @@
3535
*Forced linking strategy means that every new query type is linked to
3636
*the common feature space with hash 0, but we don't memorize
3737
*the hash and the settings for this query.
38-
*Manual linking strategy means that new query types do not induce new
39-
*feature spaces neither interact AQO somehow. In this mode the
38+
*Controlled linking strategy means that new query types do not induce
39+
*newfeature spaces neither interact AQO somehow. In this mode the
4040
*configuration of settings for different query types lies completely on
4141
*user.
42+
*Disabled strategy means that AQO is disabled for all queries.
4243
* 3. For given query type we determine its query_hash, use_aqo, learn_aqo,
4344
*fspace_hash and auto_tuning parameters.
4445
* 4. For given fspace_hash we may use its machine learning settings, but now
@@ -143,9 +144,9 @@ aqo_planner(Query *parse,
143144
use_aqo= true;
144145
auto_tuning= false;
145146
fspace_hash=0;
146-
collect_stat=true;
147+
collect_stat=false;
147148
break;
148-
caseAQO_MODE_MANUAL:
149+
caseAQO_MODE_CONTROLLED:
149150
adding_query= false;
150151
learn_aqo= false;
151152
use_aqo= false;

‎contrib/aqo/sql/aqo_manual.sqlrenamed to‎contrib/aqo/sql/aqo_controlled.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ ANALYZE aqo_test2;
3030

3131
CREATE EXTENSION aqo;
3232

33-
SETaqo.mode='manual';
33+
SETaqo.mode='controlled';
3434

3535
EXPLAIN (COSTS FALSE)
3636
SELECT*FROM aqo_test0
@@ -75,7 +75,7 @@ WHERE t1.a = t2.b AND t2.a = t3.b AND t3.a = t4.b;
7575
SELECTcount(*)FROM tmp1;
7676
DROPTABLE tmp1;
7777

78-
SETaqo.mode='manual';
78+
SETaqo.mode='controlled';
7979
UPDATE aqo_queriesSET auto_tuning=false;
8080

8181
UPDATE aqo_queriesSET learn_aqo=true;

‎contrib/aqo/sql/aqo_disabled.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ WHERE t1.a < 1 AND t3.b < 1 AND t2.c < 1 AND t3.d < 0 AND t1.a = t2.a AND t1.b =
5353
SELECTcount(*)FROM tmp1;
5454
DROPTABLE tmp1;
5555

56-
SETaqo.mode='manual';
56+
SETaqo.mode='controlled';
5757

5858
UPDATE aqo_queriesSET learn_aqo= true, use_aqo= true, auto_tuning= false;
5959

‎contrib/aqo/sql/aqo_forced.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ANALYZE aqo_test1;
2020

2121
CREATE EXTENSION aqo;
2222

23-
SETaqo.mode='manual';
23+
SETaqo.mode='controlled';
2424

2525
EXPLAIN (COSTS FALSE)
2626
SELECT*FROM aqo_test0

‎contrib/aqo/sql/aqo_intelligent.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ WHERE t1.a = t2.b AND t2.a = t3.b AND t3.a = t4.b;
147147
SELECTcount(*)FROM tmp1;
148148
DROPTABLE tmp1;
149149

150-
SETaqo.mode='manual';
150+
SETaqo.mode='controlled';
151151

152152
UPDATE aqo_queriesSET learn_aqo= false, use_aqo= false, auto_tuning= false;
153153

‎contrib/aqo/storage.c

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ find_query(int query_hash,
3838
Oidquery_index_rel_oid;
3939
IndexScanDescquery_index_scan;
4040
ScanKeyDatakey;
41+
LOCKMODEindex_lock=AccessShareLock;
4142

4243
boolfind_ok= false;
4344

@@ -51,7 +52,7 @@ find_query(int query_hash,
5152
aqo_queries_table_rv=makeRangeVar("public","aqo_queries",-1);
5253
aqo_queries_heap=heap_openrv(aqo_queries_table_rv,heap_lock);
5354

54-
query_index_rel=index_open(query_index_rel_oid,heap_lock);
55+
query_index_rel=index_open(query_index_rel_oid,index_lock);
5556
query_index_scan=index_beginscan(
5657
aqo_queries_heap,
5758
query_index_rel,
@@ -76,7 +77,7 @@ find_query(int query_hash,
7677
search_values,search_nulls);
7778

7879
index_endscan(query_index_scan);
79-
index_close(query_index_rel,heap_lock);
80+
index_close(query_index_rel,index_lock);
8081
heap_close(aqo_queries_heap,heap_lock);
8182

8283
returnfind_ok;
@@ -94,6 +95,7 @@ add_query(int query_hash, bool learn_aqo, bool use_aqo,
9495
Relationaqo_queries_heap;
9596
HeapTupletuple;
9697
LOCKMODEheap_lock=RowExclusiveLock;
98+
LOCKMODEindex_lock=RowExclusiveLock;
9799

98100
Datumvalues[5];
99101
boolnulls[5]= {false, false, false, false, false};
@@ -113,7 +115,7 @@ add_query(int query_hash, bool learn_aqo, bool use_aqo,
113115
disable_aqo_for_query();
114116
return false;
115117
}
116-
query_index_rel=index_open(query_index_rel_oid,heap_lock);
118+
query_index_rel=index_open(query_index_rel_oid,index_lock);
117119

118120
aqo_queries_table_rv=makeRangeVar("public","aqo_queries",-1);
119121
aqo_queries_heap=heap_openrv(aqo_queries_table_rv,heap_lock);
@@ -136,7 +138,7 @@ add_query(int query_hash, bool learn_aqo, bool use_aqo,
136138
}
137139
PG_END_TRY();
138140

139-
index_close(query_index_rel,heap_lock);
141+
index_close(query_index_rel,index_lock);
140142
heap_close(aqo_queries_heap,heap_lock);
141143

142144
CommandCounterIncrement();
@@ -158,6 +160,7 @@ update_query(int query_hash, bool learn_aqo, bool use_aqo,
158160
Oidquery_index_rel_oid;
159161
IndexScanDescquery_index_scan;
160162
ScanKeyDatakey;
163+
LOCKMODEindex_lock=RowExclusiveLock;
161164

162165
Datumvalues[5];
163166
boolnulls[5]= {false, false, false, false, false};
@@ -173,7 +176,7 @@ update_query(int query_hash, bool learn_aqo, bool use_aqo,
173176
aqo_queries_table_rv=makeRangeVar("public","aqo_queries",-1);
174177
aqo_queries_heap=heap_openrv(aqo_queries_table_rv,heap_lock);
175178

176-
query_index_rel=index_open(query_index_rel_oid,heap_lock);
179+
query_index_rel=index_open(query_index_rel_oid,index_lock);
177180
query_index_scan=index_beginscan(
178181
aqo_queries_heap,
179182
query_index_rel,
@@ -217,7 +220,7 @@ update_query(int query_hash, bool learn_aqo, bool use_aqo,
217220
}
218221

219222
index_endscan(query_index_scan);
220-
index_close(query_index_rel,heap_lock);
223+
index_close(query_index_rel,index_lock);
221224
heap_close(aqo_queries_heap,heap_lock);
222225

223226
CommandCounterIncrement();
@@ -236,6 +239,7 @@ add_query_text(int query_hash, const char *query_text)
236239
Relationaqo_query_texts_heap;
237240
HeapTupletuple;
238241
LOCKMODEheap_lock=RowExclusiveLock;
242+
LOCKMODEindex_lock=RowExclusiveLock;
239243

240244
Datumvalues[2];
241245
boolnulls[2]= {false, false};
@@ -252,7 +256,7 @@ add_query_text(int query_hash, const char *query_text)
252256
disable_aqo_for_query();
253257
return false;
254258
}
255-
query_index_rel=index_open(query_index_rel_oid,heap_lock);
259+
query_index_rel=index_open(query_index_rel_oid,index_lock);
256260

257261
aqo_query_texts_table_rv=makeRangeVar("public",
258262
"aqo_query_texts",
@@ -280,7 +284,7 @@ add_query_text(int query_hash, const char *query_text)
280284
PG_END_TRY();
281285

282286

283-
index_close(query_index_rel,heap_lock);
287+
index_close(query_index_rel,index_lock);
284288
heap_close(aqo_query_texts_heap,heap_lock);
285289

286290
CommandCounterIncrement();
@@ -315,6 +319,7 @@ load_fss(int fss_hash, int ncols,
315319
Oiddata_index_rel_oid;
316320
IndexScanDescdata_index_scan;
317321
ScanKeyData*key;
322+
LOCKMODEindex_lock=AccessShareLock;
318323

319324
Datumvalues[5];
320325
boolnulls[5];
@@ -331,7 +336,7 @@ load_fss(int fss_hash, int ncols,
331336
aqo_data_table_rv=makeRangeVar("public","aqo_data",-1);
332337
aqo_data_heap=heap_openrv(aqo_data_table_rv,heap_lock);
333338

334-
data_index_rel=index_open(data_index_rel_oid,heap_lock);
339+
data_index_rel=index_open(data_index_rel_oid,index_lock);
335340
data_index_scan=index_beginscan(
336341
aqo_data_heap,
337342
data_index_rel,
@@ -380,7 +385,7 @@ load_fss(int fss_hash, int ncols,
380385

381386
index_endscan(data_index_scan);
382387

383-
index_close(data_index_rel,heap_lock);
388+
index_close(data_index_rel,index_lock);
384389
heap_close(aqo_data_heap,heap_lock);
385390

386391
pfree(key);
@@ -534,6 +539,7 @@ get_aqo_stat(int query_hash)
534539
Oidstat_index_rel_oid;
535540
IndexScanDescstat_index_scan;
536541
ScanKeyDatakey;
542+
LOCKMODEindex_lock=AccessShareLock;
537543

538544
Datumvalues[9];
539545
boolnulls[9];
@@ -550,7 +556,7 @@ get_aqo_stat(int query_hash)
550556
aqo_stat_table_rv=makeRangeVar("public","aqo_query_stat",-1);
551557
aqo_stat_heap=heap_openrv(aqo_stat_table_rv,heap_lock);
552558

553-
stat_index_rel=index_open(stat_index_rel_oid,heap_lock);
559+
stat_index_rel=index_open(stat_index_rel_oid,index_lock);
554560
stat_index_scan=index_beginscan(
555561
aqo_stat_heap,
556562
stat_index_rel,
@@ -586,7 +592,7 @@ get_aqo_stat(int query_hash)
586592

587593
index_endscan(stat_index_scan);
588594

589-
index_close(stat_index_rel,heap_lock);
595+
index_close(stat_index_rel,index_lock);
590596
heap_close(aqo_stat_heap,heap_lock);
591597

592598
returnstat;
@@ -707,7 +713,7 @@ update_aqo_stat(int query_hash, QueryStat * stat)
707713

708714
index_endscan(stat_index_scan);
709715

710-
index_close(stat_index_rel,heap_lock);
716+
index_close(stat_index_rel,index_lock);
711717
heap_close(aqo_stat_heap,heap_lock);
712718

713719
CommandCounterIncrement();
@@ -839,6 +845,10 @@ my_simple_heap_update(Relation relation, ItemPointer otid, HeapTuple tup)
839845
return false;
840846
break;
841847

848+
caseHeapTupleBeingUpdated:
849+
return false;
850+
break;
851+
842852
default:
843853
elog(ERROR,"unrecognized heap_update status: %u",result);
844854
break;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp