Skip to content

Commit

Permalink
Print aqo details regardless of IsQueryDisabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandra Pervushina authored and Daniil Anisimov committed Jan 19, 2024
1 parent 1978fee commit 04fdd70
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
14 changes: 6 additions & 8 deletions postprocessing.c
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@ aqo_ExecutorEnd(QueryDesc *queryDesc)

cardinality_sum_errors = 0.;
cardinality_num_objects = 0;
njoins = -1;

if (IsQueryDisabled() || !ExtractFromQueryEnv(queryDesc))
/* AQO keep all query-related preferences at the query context.
Expand Down Expand Up @@ -996,7 +997,7 @@ print_into_explain(PlannedStmt *plannedstmt, IntoClause *into,
(*aqo_ExplainOnePlan_next)(plannedstmt, into, es, queryString,
params, planduration, queryEnv);

if (IsQueryDisabled() || !aqo_show_details)
if (!(aqo_mode != AQO_MODE_DISABLED || force_collect_stat) || !aqo_show_details)
return;

/* Report to user about aqo state only in verbose mode */
Expand Down Expand Up @@ -1031,13 +1032,10 @@ print_into_explain(PlannedStmt *plannedstmt, IntoClause *into,
* Query class provides an user the conveniently use of the AQO
* auxiliary functions.
*/
if (aqo_mode != AQO_MODE_DISABLED || force_collect_stat)
{
if (aqo_show_hash)
ExplainPropertyInteger("Query hash", NULL,
query_context.query_hash, es);
ExplainPropertyInteger("JOINS", NULL, njoins, es);
}
if (aqo_show_hash)
ExplainPropertyInteger("Query hash", NULL,
(int64) query_context.query_hash, es);
ExplainPropertyInteger("JOINS", NULL, njoins, es);
}

static void
Expand Down
5 changes: 5 additions & 0 deletions preprocessing.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ aqo_planner(Query *parse, const char *query_string, int cursorOptions,
* all execution stages.
*/
disable_aqo_for_query();
query_context.query_hash = 0;

return (*aqo_planner_next)(parse, query_string, cursorOptions, boundParams);
}
Expand Down Expand Up @@ -233,7 +234,11 @@ aqo_planner(Query *parse, const char *query_string, int cursorOptions,
*/
if (!query_context.learn_aqo && !query_context.use_aqo &&
!query_context.auto_tuning && !force_collect_stat)
{
add_deactivated_query(query_context.query_hash);
disable_aqo_for_query();
goto ignore_query_settings;
}

/*
* That we can do if query exists in database.
Expand Down

0 comments on commit 04fdd70

Please sign in to comment.