Details
-
Task
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
None
-
None
Description
We need to support ORDER/GROUP BY in EXPLAIN JSON.
MySQL's way of doing it has some good ideas: ordering_operation and grouping_operation are two different ops that one can see. But it has issues, too:
- ordering_operation is present even when no ordering takes place http://bugs.mysql.com/bug.php?id=74462
- they show "using_temporary_table": true for both duplicates_removal and "ordering_operation" http://bugs.mysql.com/bug.php?id=74661 when execution only uses one temp.table
- they ignore LIMIT.
- ordering_operation is present even when there is no "operation". Is simply using the appropriate index an "ordering operation"?
- duplicate_removal may be shown when no duplicate removal takes place: http://bugs.mysql.com/bug.php?id=74744
Looking at mysql-5.6:
bool Explain_join::shallow_explain()
{
if (begin_sort_context(ESC_ORDER_BY, CTX_ORDER_BY))
return true;
if (begin_sort_context(ESC_DISTINCT, CTX_DISTINCT))
return true;
if (begin_sort_context(ESC_GROUP_BY, CTX_GROUP_BY))
return true;
if (begin_sort_context(ESC_BUFFER_RESULT, CTX_BUFFER_RESULT))
return true;
for (size_t t= 0,
cnt= fmt->is_hierarchical() ? join->primary_tables : join->tables;
t < cnt; t++)
{
if (explain_join_tab(t))
return true;
}
if (end_sort_context(ESC_BUFFER_RESULT, CTX_BUFFER_RESULT))
return true;
if (end_sort_context(ESC_GROUP_BY, CTX_GROUP_BY))
return true;
if (end_sort_context(ESC_DISTINCT, CTX_DISTINCT))
return true;
if (end_sort_context(ESC_ORDER_BY, CTX_ORDER_BY))
return true;
return false;
}
...
bool Explain_join::explain_join_tab(size_t tab_num) they have:
if (first_non_const)
{
if (begin_simple_sort_context(ESC_ORDER_BY, CTX_SIMPLE_ORDER_BY))
return true;
if (begin_simple_sort_context(ESC_DISTINCT, CTX_SIMPLE_DISTINCT))
return true;
if (begin_simple_sort_context(ESC_GROUP_BY, CTX_SIMPLE_GROUP_BY))
return true;
}
you get the idea