summaryrefslogtreecommitdiff
path: root/sql/opt_trace.cc
diff options
context:
space:
mode:
authorVarun Gupta <varun.gupta@mariadb.com>2019-09-10 14:01:31 +0530
committerVarun Gupta <varun.gupta@mariadb.com>2019-09-11 04:32:40 +0530
commit71c57bcf8f87078772ccf5387583487bcd5d86f8 (patch)
tree2617f883a81f1593bc91a4a9038deb0984887e54 /sql/opt_trace.cc
parent7b988e5cebf3c6979694056e474f8256b8466696 (diff)
downloadmariadb-git-71c57bcf8f87078772ccf5387583487bcd5d86f8.tar.gz
Moved the function trace_plan_prefix to the optimizer trace file
Also added comments for trace_plan_prefix and the class Json_writer_temp_disable
Diffstat (limited to 'sql/opt_trace.cc')
-rw-r--r--sql/opt_trace.cc34
1 files changed, 34 insertions, 0 deletions
diff --git a/sql/opt_trace.cc b/sql/opt_trace.cc
index c80037ba864..7c82ba829bc 100644
--- a/sql/opt_trace.cc
+++ b/sql/opt_trace.cc
@@ -413,6 +413,12 @@ size_t Opt_trace_context::remaining_mem_size()
return max_mem_size;
}
+/*
+ Disable tracing for children if the current trace is already present.
+ Currently only one trace is stored and there is no mechanism
+ to restore traces, so disabling tracing for children is the best option.
+*/
+
bool Opt_trace_context::disable_tracing_if_required()
{
if (current_trace)
@@ -631,6 +637,34 @@ void add_table_scan_values_to_trace(THD *thd, JOIN_TAB *tab)
.add("cost", tab->read_time);
}
+
+/*
+ @brief
+ Add the tables inside a partial join to the optimizer trace
+
+ @param join join handler
+ @param idx length of the partial QEP in 'join->positions'
+ @table_map map of all non-const tables of the join
+
+ @note
+ This function is used during best_access_path to print the tables
+ inside the partial join that were considered doing the cost based
+ analysis of the various join orders.
+*/
+
+void trace_plan_prefix(JOIN *join, uint idx, table_map join_tables)
+{
+ THD *const thd= join->thd;
+ Json_writer_array plan_prefix(thd, "plan_prefix");
+ for (uint i= 0; i < idx; i++)
+ {
+ TABLE_LIST *const tr= join->positions[i].table->tab_list;
+ if (!(tr->map & join_tables))
+ plan_prefix.add_table_name(join->positions[i].table);
+ }
+}
+
+
/*
Print the join order of all the tables for top level select.