diff options
author | Sergey Petrunya <psergey@askmonty.org> | 2013-10-09 13:07:46 +0400 |
---|---|---|
committer | Sergey Petrunya <psergey@askmonty.org> | 2013-10-09 13:07:46 +0400 |
commit | 3c6ac6694d291dc454af6f9042c9217afd7fff9b (patch) | |
tree | ab9360d4e28c4ecddfccaf927c3f65a93ce683e9 /sql/sql_delete.cc | |
parent | 161d68759433b0315a6b95209d3db86be411a686 (diff) | |
download | mariadb-git-3c6ac6694d291dc454af6f9042c9217afd7fff9b.tar.gz |
MDEV-3798: EXPLAIN UPDATE/DELETE
- Produce correct #rows for ORDER BY ... LIMIT N queries that take advantage of
ordered index read to read only N rows.
Diffstat (limited to 'sql/sql_delete.cc')
-rw-r--r-- | sql/sql_delete.cc | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 15dfe3e6c7c..00193800b93 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -59,7 +59,7 @@ void Delete_plan::save_explain_data(Explain_query *query) { explain->deleting_all_rows= true; explain->select_type= "SIMPLE"; - explain->rows= table_rows; + explain->rows= scanned_rows; } else { @@ -161,7 +161,7 @@ void Update_plan::save_explain_data_intern(Explain_query *query, } // key_len stays NULL } - explain->rows= select ? select->records : table_rows; + explain->rows= scanned_rows; if (select && select->quick && select->quick->get_type() == QUICK_SELECT_I::QS_TYPE_RANGE) @@ -421,6 +421,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, if (options & OPTION_QUICK) (void) table->file->extra(HA_EXTRA_QUICK); + query_plan.scanned_rows= select? select->records: table->file->stats.records; if (order) { table->update_const_key_parts(conds); @@ -432,14 +433,19 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, query_plan.index= MAX_KEY; } else + { + ha_rows scanned_limit= query_plan.scanned_rows; query_plan.index= get_index_for_order(order, table, select, limit, + &scanned_limit, &query_plan.using_filesort, &reverse); + if (!query_plan.using_filesort) + query_plan.scanned_rows= scanned_limit; + } } query_plan.select= select; query_plan.possible_keys= select? select->possible_keys: key_map(0); - query_plan.table_rows= table->file->stats.records; /* Ok, we have generated a query plan for the DELETE. |