summaryrefslogtreecommitdiff
path: root/sql/sql_explain.cc
diff options
context:
space:
mode:
authorGalina Shalygina <galina.shalygina@mariadb.com>2018-08-16 00:24:52 +0300
committerGalina Shalygina <galina.shalygina@mariadb.com>2018-09-28 23:50:22 +0300
commit8d5a11122c32f4d9eb87536886c6e893377bdd07 (patch)
treeab8cc222d336acd0006a544abb362affc149f671 /sql/sql_explain.cc
parentbefc09f00263d5375b2bb2ea0fac70b6cb0cb7fd (diff)
downloadmariadb-git-8d5a11122c32f4d9eb87536886c6e893377bdd07.tar.gz
MDEV-16188: Use in-memory PK filters built from range index scans
First phase: make optimizer choose to use filter and show it in EXPLAIN.
Diffstat (limited to 'sql/sql_explain.cc')
-rw-r--r--sql/sql_explain.cc32
1 files changed, 29 insertions, 3 deletions
diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc
index 1c45b05ccc5..23bc1e906a0 100644
--- a/sql/sql_explain.cc
+++ b/sql/sql_explain.cc
@@ -1146,6 +1146,15 @@ void Explain_table_access::fill_key_len_str(String *key_len_str) const
length= longlong10_to_str(hash_next_key.get_key_len(), buf, 10) - buf;
key_len_str->append(buf, length);
}
+
+ if (key.get_filter_key_length() != (uint)-1)
+ {
+ char buf[64];
+ size_t length;
+ key_len_str->append(',');
+ length= longlong10_to_str(key.get_filter_key_length(), buf, 10) - buf;
+ key_len_str->append(buf, length);
+ }
}
@@ -1274,12 +1283,20 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai
push_string_list(thd, &item_list, ref_list, &ref_list_buf);
/* `rows` */
+ StringBuffer<64> rows_str;
if (rows_set)
{
+ rows_str.append_ulonglong((ulonglong)rows);
+
+ if (is_filter_set())
+ {
+ rows_str.append(" (");
+ rows_str.append_ulonglong(filter_perc);
+ rows_str.append("%)");
+ }
item_list.push_back(new (mem_root)
- Item_int(thd, (longlong) (ulonglong) rows,
- MY_INT64_NUM_DECIMAL_DIGITS),
- mem_root);
+ Item_string_sys(thd, rows_str.ptr(),
+ rows_str.length()), mem_root);
}
else
item_list.push_back(item_null, mem_root);
@@ -1359,6 +1376,15 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai
extra_buf.append(STRING_WITH_LEN("Using filesort"));
}
+ if (is_filter_set())
+ {
+ if (first)
+ first= false;
+ else
+ extra_buf.append(STRING_WITH_LEN("; "));
+ extra_buf.append(STRING_WITH_LEN("Using filter"));
+ }
+
item_list.push_back(new (mem_root)
Item_string_sys(thd, extra_buf.ptr(),
extra_buf.length()),