diff options
author | Sergei Petrunia <psergey@askmonty.org> | 2014-12-01 21:35:31 +0300 |
---|---|---|
committer | Sergei Petrunia <psergey@askmonty.org> | 2014-12-01 21:35:31 +0300 |
commit | 753718c20194f9f04432a5657a661eb6e9440483 (patch) | |
tree | 27da8760e0b7e436f3d3751049fb2b215cfc4912 /sql/sql_explain.h | |
parent | c46eadb2b33ca152525a18d9b5425fedbef7f277 (diff) | |
download | mariadb-git-753718c20194f9f04432a5657a661eb6e9440483.tar.gz |
EXPLAIN FORMAT=JSON: support SJ-Materialization
- Switch Explain data structure from "flat" representation of
SJ-Materialization into nested one.
- Update functions that print tabular output to operate on the
nested structure.
- Add function to generate JSON output.
Diffstat (limited to 'sql/sql_explain.h')
-rw-r--r-- | sql/sql_explain.h | 86 |
1 files changed, 52 insertions, 34 deletions
diff --git a/sql/sql_explain.h b/sql/sql_explain.h index 9cdaacd61ed..20e2f856840 100644 --- a/sql/sql_explain.h +++ b/sql/sql_explain.h @@ -94,7 +94,8 @@ public: enum explain_node_type { EXPLAIN_UNION, - EXPLAIN_SELECT, + EXPLAIN_SELECT, + EXPLAIN_BASIC_JOIN, EXPLAIN_UPDATE, EXPLAIN_DELETE, EXPLAIN_INSERT @@ -144,6 +145,49 @@ public: class Explain_table_access; +/* + A basic join. This is only used for SJ-Materialization nests. + + Basic join doesn't have ORDER/GROUP/DISTINCT operations. It also cannot be + degenerate. + + It has its own select_id. +*/ +class Explain_basic_join : public Explain_node +{ +public: + enum explain_node_type get_type() { return EXPLAIN_BASIC_JOIN; } + + Explain_basic_join() : join_tabs(NULL) {} + ~Explain_basic_join(); + + bool add_table(Explain_table_access *tab) + { + if (!join_tabs) + { + join_tabs= (Explain_table_access**) my_malloc(sizeof(Explain_table_access*) * + MAX_TABLES, MYF(0)); + n_join_tabs= 0; + } + join_tabs[n_join_tabs++]= tab; + return false; + } + + int get_select_id() { return select_id; } + + int select_id; + + int print_explain(Explain_query *query, select_result_sink *output, + uint8 explain_flags, bool is_analyze); + void print_explain_json(Explain_query *query, Json_writer *writer, + bool is_analyze); + + /* A flat array of Explain structs for tables. */ + Explain_table_access** join_tabs; + uint n_join_tabs; +}; + + /* EXPLAIN structure for a SELECT. @@ -159,30 +203,16 @@ class Explain_table_access; a way get node's children. */ -class Explain_select : public Explain_node +class Explain_select : public Explain_basic_join { public: enum explain_node_type get_type() { return EXPLAIN_SELECT; } Explain_select() : - message(NULL), join_tabs(NULL), + message(NULL), using_temporary(false), using_filesort(false) {} - - ~Explain_select(); - bool add_table(Explain_table_access *tab) - { - if (!join_tabs) - { - join_tabs= (Explain_table_access**) my_malloc(sizeof(Explain_table_access*) * - MAX_TABLES, MYF(0)); - n_join_tabs= 0; - } - join_tabs[n_join_tabs++]= tab; - return false; - } - /* This is used to save the results of "late" test_if_skip_sort_order() calls that are made from JOIN::exec @@ -190,24 +220,14 @@ public: void replace_table(uint idx, Explain_table_access *new_tab); public: - int select_id; const char *select_type; - int get_select_id() { return select_id; } - /* If message != NULL, this is a degenerate join plan, and all subsequent members have no info */ const char *message; - /* - A flat array of Explain structs for tables. The order is "just like EXPLAIN - would print them". - */ - Explain_table_access** join_tabs; - uint n_join_tabs; - /* Global join attributes. In tabular form, they are printed on the first row */ bool using_temporary; bool using_filesort; @@ -521,19 +541,15 @@ public: non_merged_sjm_number(0), where_cond(NULL), cache_cond(NULL), - pushed_index_cond(NULL) + pushed_index_cond(NULL), + sjm_nest(NULL) {} + ~Explain_table_access() { delete sjm_nest; } void push_extra(enum explain_extra_tag extra_tag); /* Internals */ public: - /* - 0 means this tab is not inside SJM nest and should use Explain_select's id - other value means the tab is inside an SJM nest. - */ - int sjm_nest_select_id; - /* id and 'select_type' are cared-of by the parent Explain_select */ StringBuffer<32> table_name; @@ -610,6 +626,8 @@ public: Item *pushed_index_cond; + Explain_basic_join *sjm_nest; + int print_explain(select_result_sink *output, uint8 explain_flags, bool is_analyze, uint select_id, const char *select_type, |