diff options
author | Sergey Petrunya <psergey@askmonty.org> | 2013-06-27 17:02:44 +0400 |
---|---|---|
committer | Sergey Petrunya <psergey@askmonty.org> | 2013-06-27 17:02:44 +0400 |
commit | 5422098b758dfec801b32c833b8840ec96e00081 (patch) | |
tree | 9be733fa837697540602ae18aa1cf91f3ef7028e | |
parent | c0f7efb1aeeabebe502a786cc461a9d76bf18487 (diff) | |
download | mariadb-git-5422098b758dfec801b32c833b8840ec96e00081.tar.gz |
More of code cleanup
-rw-r--r-- | sql/opt_qpf.h | 54 | ||||
-rw-r--r-- | sql/sql_select.cc | 11 |
2 files changed, 33 insertions, 32 deletions
diff --git a/sql/opt_qpf.h b/sql/opt_qpf.h index 2af04ab28a7..b82f004ff7f 100644 --- a/sql/opt_qpf.h +++ b/sql/opt_qpf.h @@ -50,18 +50,19 @@ class QPF_table_access; Query Plan Footprint of a SELECT. A select can be: - - a degenerate case. In this case, message!=NULL, and it contains a - description of what kind of degenerate case it is (e.g. "Impossible - WHERE"). - - a join. Here join_tabs has an array of JOIN_TAB query plan footprints. + 1. A degenerate case. In this case, message!=NULL, and it contains a + description of what kind of degenerate case it is (e.g. "Impossible + WHERE"). + 2. a non-degenrate join. In this case, join_tabs describes the join. In the non-degenerate case, a SELECT may have a GROUP BY/ORDER BY operation. - In both cases, a select may have children selects (see QPF_node) + + In both cases, the select may have children nodes. class QPF_node provides + a way get node's children. */ class QPF_select : public QPF_node { - /*Construction interface */ public: enum qpf_node_type get_type() { return QPF_SELECT; } @@ -107,10 +108,6 @@ public: bool using_temporary; bool using_filesort; - void print_tabular(select_result_sink *output, uint8 explain_flags//, - //bool *printed_anything - ); - int print_explain(QPF_query *query, select_result_sink *output, uint8 explain_flags); }; @@ -223,9 +220,13 @@ public: private: Dynamic_array<QPF_union*> unions; Dynamic_array<QPF_select*> selects; - //QPF_union *unions[MAX_TABLES]; - //QPF_select *selects[MAX_TABLES]; - + + /* + Debugging aid: count how many times add_node() was called. Ideally, it + should be one, we currently allow O(1) query plan saves for each + select or union. The goal is not to have O(#rows_in_some_table), which + is unacceptable. + */ longlong operations; }; @@ -303,9 +304,6 @@ public: uint key_no; uint key_length; - Dynamic_array<enum Extra_tag> extra_tags; - - //temporary: bool key_set; /* not set means 'NULL' should be printed */ StringBuffer<64> key; @@ -315,15 +313,18 @@ public: bool ref_set; /* not set means 'NULL' should be printed */ StringBuffer<64> ref; - bool rows_set; + bool rows_set; /* not set means 'NULL' should be printed */ ha_rows rows; - bool filtered_set; + bool filtered_set; /* not set means 'NULL' should be printed */ double filtered; - /* Various stuff for 'Extra' column*/ - uint join_cache_level; - + /* + Contents of the 'Extra' column. Some are converted into strings, some have + parameters, values for which are stored below. + */ + Dynamic_array<enum Extra_tag> extra_tags; + // Valid if ET_USING tag is present StringBuffer<64> quick_info; @@ -351,7 +352,10 @@ private: /* - Query Plan Footprint for an UPDATE statement + Query Plan Footprint for single-table UPDATE. + + This is similar to QPF_table_access, except that it is more restrictive. + Also, it can have UPDATE operation options, but currently there aren't any. */ class QPF_update : public QPF_node @@ -382,12 +386,16 @@ public: /* - Query Plan Footprint for a DELETE statement + Query Plan Footprint for a single-table DELETE. */ class QPF_delete: public QPF_update { public: + /* + TRUE means we're going to call handler->delete_all_rows() and not read any + rows. + */ bool deleting_all_rows; virtual enum qpf_node_type get_type() { return QPF_DELETE; } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 201d1a6cc80..ed1cb35c29a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -22448,9 +22448,9 @@ void append_possible_keys(String *str, TABLE *table, key_map possible_keys) /* Save Query Plan Footprint - push_extra - P + @note + Currently, this function may be called multiple times */ int JOIN::save_qpf(QPF_query *output, bool need_tmp_table, bool need_order, @@ -22471,11 +22471,6 @@ int JOIN::save_qpf(QPF_query *output, bool need_tmp_table, bool need_order, DBUG_ASSERT(have_query_plan == QEP_AVAILABLE); /* Don't log this into the slow query log */ - - /* - NOTE: the number/types of items pushed into item_list must be in sync with - EXPLAIN column types as they're "defined" in THD::send_explain_fields() - */ if (message) { QPF_select *qp_sel; @@ -22998,8 +22993,6 @@ int JOIN::save_qpf(QPF_query *output, bool need_tmp_table, bool need_order, output->add_node(qp_sel); } - //TODO: can a UNION have subquery children that are not union members? yes, - //perhaps... for (SELECT_LEX_UNIT *unit= join->select_lex->first_inner_unit(); unit; unit= unit->next_unit()) |