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

Commit8810877

Browse files
committed
Change AQO code caused by planner's interface improvements (6aba63ef3e60).
Also, some code readability improvements were made.
1 parent35ef80b commit8810877

File tree

2 files changed

+60
-42
lines changed

2 files changed

+60
-42
lines changed

‎aqo.h‎

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ extern double log_selectivity_lower_bound;
243243
/* Parameters for current query */
244244
externQueryContextDataquery_context;
245245
externintnjoins;
246-
externchar*query_text;
246+
externchar*query_text;
247247

248248
/* Memory context for long-live data */
249249
externMemoryContextAQOMemoryContext;
@@ -253,63 +253,64 @@ extern post_parse_analyze_hook_type prev_post_parse_analyze_hook;
253253
externplanner_hook_typeprev_planner_hook;
254254
externExecutorStart_hook_typeprev_ExecutorStart_hook;
255255
externExecutorEnd_hook_typeprev_ExecutorEnd_hook;
256-
externset_baserel_rows_estimate_hook_type
257-
prev_set_baserel_rows_estimate_hook;
258-
externget_parameterized_baserel_size_hook_type
259-
prev_get_parameterized_baserel_size_hook;
260-
externset_joinrel_size_estimates_hook_type
261-
prev_set_joinrel_size_estimates_hook;
262-
externget_parameterized_joinrel_size_hook_type
263-
prev_get_parameterized_joinrel_size_hook;
264-
externcopy_generic_path_info_hook_type
265-
prev_copy_generic_path_info_hook;
256+
externset_baserel_rows_estimate_hook_type
257+
prev_set_baserel_rows_estimate_hook;
258+
externget_parameterized_baserel_size_hook_type
259+
prev_get_parameterized_baserel_size_hook;
260+
externset_joinrel_size_estimates_hook_type
261+
prev_set_joinrel_size_estimates_hook;
262+
externget_parameterized_joinrel_size_hook_type
263+
prev_get_parameterized_joinrel_size_hook;
264+
externcopy_generic_path_info_hook_typeprev_copy_generic_path_info_hook;
266265
externExplainOnePlan_hook_typeprev_ExplainOnePlan_hook;
267266

268267
externvoidppi_hook(ParamPathInfo*ppi);
269268

270269
/* Hash functions */
271-
intget_query_hash(Query*parse,constchar*query_text);
270+
intget_query_hash(Query*parse,constchar*query_text);
272271
externintget_fss_for_object(List*clauselist,List*selectivities,
273-
List*relidslist,int*nfeatures,double**features);
274-
voidget_eclasses(List*clauselist,int*nargs,
275-
int**args_hash,int**eclass_hash);
276-
intget_clause_hash(Expr*clause,intnargs,
277-
int*args_hash,int*eclass_hash);
272+
List*relidslist,int*nfeatures,
273+
double**features);
274+
voidget_eclasses(List*clauselist,int*nargs,int**args_hash,
275+
int**eclass_hash);
276+
intget_clause_hash(Expr*clause,intnargs,int*args_hash,int*eclass_hash);
278277

279278

280279
/* Storage interaction */
281280
boolfind_query(intquery_hash,
282-
Datum*search_values,
283-
bool*search_nulls);
281+
Datum*search_values,
282+
bool*search_nulls);
284283
booladd_query(intquery_hash,boollearn_aqo,booluse_aqo,
285-
intfspace_hash,boolauto_tuning);
284+
intfspace_hash,boolauto_tuning);
286285
boolupdate_query(intquery_hash,boollearn_aqo,booluse_aqo,
287-
intfspace_hash,boolauto_tuning);
288-
booladd_query_text(intquery_hash,constchar*query_text);
286+
intfspace_hash,boolauto_tuning);
287+
booladd_query_text(intquery_hash,constchar*query_text);
289288
boolload_fss(intfss_hash,intncols,
290289
double**matrix,double*targets,int*rows);
291290
externboolupdate_fss(intfss_hash,intnrows,intncols,
292291
double**matrix,double*targets);
293-
QueryStat*get_aqo_stat(intquery_hash);
294-
voidupdate_aqo_stat(intquery_hash,QueryStat*stat);
295-
voidinit_deactivated_queries_storage(void);
296-
voidfini_deactivated_queries_storage(void);
297-
boolquery_is_deactivated(intquery_hash);
298-
voidadd_deactivated_query(intquery_hash);
292+
QueryStat*get_aqo_stat(intquery_hash);
293+
voidupdate_aqo_stat(intquery_hash,QueryStat*stat);
294+
voidinit_deactivated_queries_storage(void);
295+
voidfini_deactivated_queries_storage(void);
296+
boolquery_is_deactivated(intquery_hash);
297+
voidadd_deactivated_query(intquery_hash);
299298

300299
/* Query preprocessing hooks */
301-
voidget_query_text(ParseState*pstate,Query*query);
300+
voidget_query_text(ParseState*pstate,Query*query);
302301
PlannedStmt*call_default_planner(Query*parse,
303-
intcursorOptions,
304-
ParamListInfoboundParams);
302+
constchar*query_string,
303+
intcursorOptions,
304+
ParamListInfoboundParams);
305305
PlannedStmt*aqo_planner(Query*parse,
306-
intcursorOptions,
307-
ParamListInfoboundParams);
306+
constchar*query_string,
307+
intcursorOptions,
308+
ParamListInfoboundParams);
308309
voidprint_into_explain(PlannedStmt*plannedstmt,IntoClause*into,
309-
ExplainState*es,constchar*queryString,
310-
ParamListInfoparams,constinstr_time*planduration,
311-
QueryEnvironment*queryEnv);
312-
voiddisable_aqo_for_query(void);
310+
ExplainState*es,constchar*queryString,
311+
ParamListInfoparams,constinstr_time*planduration,
312+
QueryEnvironment*queryEnv);
313+
voiddisable_aqo_for_query(void);
313314

314315
/* Cardinality estimation hooks */
315316
externvoidaqo_set_baserel_rows_estimate(PlannerInfo*root,RelOptInfo*rel);

‎preprocessing.c‎

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,20 @@ get_query_text(ParseState *pstate, Query *query)
9191
*/
9292
PlannedStmt*
9393
call_default_planner(Query*parse,
94+
constchar*query_string,
9495
intcursorOptions,
9596
ParamListInfoboundParams)
9697
{
9798
if (prev_planner_hook)
98-
returnprev_planner_hook(parse,cursorOptions,boundParams);
99+
returnprev_planner_hook(parse,
100+
query_string,
101+
cursorOptions,
102+
boundParams);
99103
else
100-
returnstandard_planner(parse,cursorOptions,boundParams);
104+
returnstandard_planner(parse,
105+
query_string,
106+
cursorOptions,
107+
boundParams);
101108
}
102109

103110
/*
@@ -110,6 +117,7 @@ call_default_planner(Query *parse,
110117
*/
111118
PlannedStmt*
112119
aqo_planner(Query*parse,
120+
constchar*query_string,
113121
intcursorOptions,
114122
ParamListInfoboundParams)
115123
{
@@ -134,7 +142,10 @@ aqo_planner(Query *parse,
134142
RecoveryInProgress())
135143
{
136144
disable_aqo_for_query();
137-
returncall_default_planner(parse,cursorOptions,boundParams);
145+
returncall_default_planner(parse,
146+
query_string,
147+
cursorOptions,
148+
boundParams);
138149
}
139150

140151
INSTR_TIME_SET_CURRENT(query_context.query_starttime);
@@ -144,7 +155,10 @@ aqo_planner(Query *parse,
144155
if (query_is_deactivated(query_context.query_hash))
145156
{
146157
disable_aqo_for_query();
147-
returncall_default_planner(parse,cursorOptions,boundParams);
158+
returncall_default_planner(parse,
159+
query_string,
160+
cursorOptions,
161+
boundParams);
148162
}
149163

150164
query_is_stored=find_query(query_context.query_hash,&query_params[0],
@@ -274,7 +288,10 @@ aqo_planner(Query *parse,
274288
query_context.fspace_hash=query_context.query_hash;
275289
}
276290

277-
returncall_default_planner(parse,cursorOptions,boundParams);
291+
returncall_default_planner(parse,
292+
query_string,
293+
cursorOptions,
294+
boundParams);
278295
}
279296

280297
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp