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 22, 2024
1 parent e4999b7 commit 33a64e0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion aqo.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ MemoryContext AQOLearnMemCtx = NULL;
MemoryContext AQOStorageMemCtx = NULL;

/* Additional plan info */
int njoins;
int njoins = -1;


/*****************************************************************************
Expand Down
16 changes: 7 additions & 9 deletions postprocessing.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ static void StoreToQueryEnv(QueryDesc *queryDesc);
static void StorePlanInternals(QueryDesc *queryDesc);
static bool ExtractFromQueryEnv(QueryDesc *queryDesc);


/*
* This is the critical section: only one runner is allowed to be inside this
* function for one feature subspace.
Expand Down Expand Up @@ -766,6 +765,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 +996,8 @@ 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 @@ -130,6 +130,7 @@ aqo_planner(Query *parse, const char *query_string, int cursorOptions,
*/
MemoryContextSwitchTo(oldctx);
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 33a64e0

Please sign in to comment.