summaryrefslogtreecommitdiff
path: root/sql/sql_explain.cc
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2015-04-12 06:07:58 +0200
committerSergei Petrunia <psergey@askmonty.org>2015-04-12 06:07:58 +0200
commit2bbf3b89f66e391b126108fc3c4d4a5d2e440a38 (patch)
treeb0a825e0d2d14db7be50bb418c7e24208b27e983 /sql/sql_explain.cc
parentcc8da9b75aa8ed99be8ef5a7a765c9a4fb059014 (diff)
downloadmariadb-git-2bbf3b89f66e391b126108fc3c4d4a5d2e440a38.tar.gz
MDEV-7836: ANALYZE FORMAT=JSON should provide info about GROUP/ORDER BY
Fix EXPLAIN FORMAT=JSON to produce output that's not worse than the tabular form.
Diffstat (limited to 'sql/sql_explain.cc')
-rw-r--r--sql/sql_explain.cc20
1 files changed, 18 insertions, 2 deletions
diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc
index 89df39c180c..aad4da7eb8b 100644
--- a/sql/sql_explain.cc
+++ b/sql/sql_explain.cc
@@ -818,9 +818,19 @@ void Explain_select::print_explain_json(Explain_query *query,
if (using_temporary)
{
started_objects= 1;
+ if (using_filesort)
+ {
+ started_objects++;
+ writer->add_member("filesort").start_object();
+ }
writer->add_member("temporary_table").start_object();
writer->add_member("function").add_str("buffer");
}
+ else
+ {
+ if (using_filesort)
+ first_table_sort= &ops_tracker.filesort_tracker[0];
+ }
}
Explain_basic_join::print_explain_json_interns(query, writer, is_analyze,
@@ -1293,7 +1303,12 @@ void add_json_keyset(Json_writer *writer, const char *elem_name,
/*
@param fs_tracker Normally NULL. When not NULL, it means that the join tab
- used filesort.
+ used filesort to pre-sort the data. Then, sorted data
+ was read and the rest of the join was executed.
+
+ @note
+ EXPLAIN command will check whether fs_tracker is present, but it can't use
+ any value from fs_tracker (these are only valid for ANALYZE).
*/
void Explain_table_access::print_explain_json(Explain_query *query,
@@ -1330,7 +1345,8 @@ void Explain_table_access::print_explain_json(Explain_query *query,
}
}
writer->add_member("filesort").start_object();
- fs_tracker->print_json(writer);
+ if (is_analyze)
+ fs_tracker->print_json(writer);
}
if (bka_type.is_using_jbuf())