mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-27699 ANALYZE FORMAT=JSON fields are incorrect for UNION ALL queries
UNION ALL queries are a subject of optimization introduced in MDEV-334 when creation of a temporary table is skipped. While there is a check for this optimization in Explain_union::print_explain() there was no such in Explain_union::print_explain_json(). This resulted in printing irrelevant data like: "union_result": { "table_name": "<union2,3>", "access_type": "ALL", "r_loops": 0, "r_rows": null in case when creation of the temporary table was actually optimized out. This commits adds a check whether the temporary table was actually created during the UNION ALL processing and eliminates printing of the irrelevant data.
This commit is contained in:
@ -4050,10 +4050,6 @@ ANALYZE
|
||||
{
|
||||
"query_block": {
|
||||
"union_result": {
|
||||
"table_name": "<union1,4>",
|
||||
"access_type": "ALL",
|
||||
"r_loops": 0,
|
||||
"r_rows": null,
|
||||
"query_specifications": [
|
||||
{
|
||||
"query_block": {
|
||||
|
@ -10742,8 +10742,6 @@ EXPLAIN
|
||||
"materialized": {
|
||||
"query_block": {
|
||||
"union_result": {
|
||||
"table_name": "<union2,3>",
|
||||
"access_type": "ALL",
|
||||
"query_specifications": [
|
||||
{
|
||||
"query_block": {
|
||||
@ -14718,8 +14716,6 @@ EXPLAIN
|
||||
"materialized": {
|
||||
"query_block": {
|
||||
"union_result": {
|
||||
"table_name": "<union2,3>",
|
||||
"access_type": "ALL",
|
||||
"query_specifications": [
|
||||
{
|
||||
"query_block": {
|
||||
@ -14940,8 +14936,6 @@ EXPLAIN
|
||||
"materialized": {
|
||||
"query_block": {
|
||||
"union_result": {
|
||||
"table_name": "<union2,3,4>",
|
||||
"access_type": "ALL",
|
||||
"query_specifications": [
|
||||
{
|
||||
"query_block": {
|
||||
|
@ -247,8 +247,6 @@ EXPLAIN
|
||||
{
|
||||
"query_block": {
|
||||
"union_result": {
|
||||
"table_name": "<union1,2>",
|
||||
"access_type": "ALL",
|
||||
"query_specifications": [
|
||||
{
|
||||
"query_block": {
|
||||
|
@ -1304,8 +1304,6 @@ EXPLAIN
|
||||
{
|
||||
"query_block": {
|
||||
"union_result": {
|
||||
"table_name": "<unit1>",
|
||||
"access_type": "ALL",
|
||||
"query_specifications": [
|
||||
{
|
||||
"query_block": {
|
||||
@ -1525,8 +1523,6 @@ EXPLAIN
|
||||
{
|
||||
"query_block": {
|
||||
"union_result": {
|
||||
"table_name": "<union1,2>",
|
||||
"access_type": "ALL",
|
||||
"query_specifications": [
|
||||
{
|
||||
"query_block": {
|
||||
@ -1589,8 +1585,6 @@ EXPLAIN
|
||||
{
|
||||
"query_block": {
|
||||
"union_result": {
|
||||
"table_name": "<union1,2>",
|
||||
"access_type": "ALL",
|
||||
"query_specifications": [
|
||||
{
|
||||
"query_block": {
|
||||
@ -1633,8 +1627,6 @@ EXPLAIN
|
||||
{
|
||||
"query_block": {
|
||||
"union_result": {
|
||||
"table_name": "<union1,2,3>",
|
||||
"access_type": "ALL",
|
||||
"query_specifications": [
|
||||
{
|
||||
"query_block": {
|
||||
@ -1677,10 +1669,6 @@ ANALYZE
|
||||
{
|
||||
"query_block": {
|
||||
"union_result": {
|
||||
"table_name": "<unit1>",
|
||||
"access_type": "ALL",
|
||||
"r_loops": 0,
|
||||
"r_rows": null,
|
||||
"query_specifications": [
|
||||
{
|
||||
"query_block": {
|
||||
@ -1908,10 +1896,6 @@ ANALYZE
|
||||
{
|
||||
"query_block": {
|
||||
"union_result": {
|
||||
"table_name": "<union1,2>",
|
||||
"access_type": "ALL",
|
||||
"r_loops": 0,
|
||||
"r_rows": null,
|
||||
"query_specifications": [
|
||||
{
|
||||
"query_block": {
|
||||
@ -1976,10 +1960,6 @@ ANALYZE
|
||||
{
|
||||
"query_block": {
|
||||
"union_result": {
|
||||
"table_name": "<union1,2>",
|
||||
"access_type": "ALL",
|
||||
"r_loops": 0,
|
||||
"r_rows": null,
|
||||
"query_specifications": [
|
||||
{
|
||||
"query_block": {
|
||||
@ -2022,10 +2002,6 @@ ANALYZE
|
||||
{
|
||||
"query_block": {
|
||||
"union_result": {
|
||||
"table_name": "<union1,2,3>",
|
||||
"access_type": "ALL",
|
||||
"r_loops": 0,
|
||||
"r_rows": null,
|
||||
"query_specifications": [
|
||||
{
|
||||
"query_block": {
|
||||
|
@ -1302,8 +1302,6 @@ EXPLAIN
|
||||
{
|
||||
"query_block": {
|
||||
"union_result": {
|
||||
"table_name": "<unit1>",
|
||||
"access_type": "ALL",
|
||||
"query_specifications": [
|
||||
{
|
||||
"query_block": {
|
||||
@ -1523,8 +1521,6 @@ EXPLAIN
|
||||
{
|
||||
"query_block": {
|
||||
"union_result": {
|
||||
"table_name": "<union1,2>",
|
||||
"access_type": "ALL",
|
||||
"query_specifications": [
|
||||
{
|
||||
"query_block": {
|
||||
@ -1587,8 +1583,6 @@ EXPLAIN
|
||||
{
|
||||
"query_block": {
|
||||
"union_result": {
|
||||
"table_name": "<union1,2>",
|
||||
"access_type": "ALL",
|
||||
"query_specifications": [
|
||||
{
|
||||
"query_block": {
|
||||
@ -1631,8 +1625,6 @@ EXPLAIN
|
||||
{
|
||||
"query_block": {
|
||||
"union_result": {
|
||||
"table_name": "<union1,2,3>",
|
||||
"access_type": "ALL",
|
||||
"query_specifications": [
|
||||
{
|
||||
"query_block": {
|
||||
@ -1675,10 +1667,6 @@ ANALYZE
|
||||
{
|
||||
"query_block": {
|
||||
"union_result": {
|
||||
"table_name": "<unit1>",
|
||||
"access_type": "ALL",
|
||||
"r_loops": 0,
|
||||
"r_rows": null,
|
||||
"query_specifications": [
|
||||
{
|
||||
"query_block": {
|
||||
@ -1906,10 +1894,6 @@ ANALYZE
|
||||
{
|
||||
"query_block": {
|
||||
"union_result": {
|
||||
"table_name": "<union1,2>",
|
||||
"access_type": "ALL",
|
||||
"r_loops": 0,
|
||||
"r_rows": null,
|
||||
"query_specifications": [
|
||||
{
|
||||
"query_block": {
|
||||
@ -1974,10 +1958,6 @@ ANALYZE
|
||||
{
|
||||
"query_block": {
|
||||
"union_result": {
|
||||
"table_name": "<union1,2>",
|
||||
"access_type": "ALL",
|
||||
"r_loops": 0,
|
||||
"r_rows": null,
|
||||
"query_specifications": [
|
||||
{
|
||||
"query_block": {
|
||||
@ -2020,10 +2000,6 @@ ANALYZE
|
||||
{
|
||||
"query_block": {
|
||||
"union_result": {
|
||||
"table_name": "<union1,2,3>",
|
||||
"access_type": "ALL",
|
||||
"r_loops": 0,
|
||||
"r_rows": null,
|
||||
"query_specifications": [
|
||||
{
|
||||
"query_block": {
|
||||
|
@ -581,7 +581,8 @@ void Explain_union::print_explain_json(Explain_query *query,
|
||||
else
|
||||
writer->add_member("union_result").start_object();
|
||||
|
||||
// using_temporary_table
|
||||
if (using_tmp)
|
||||
{
|
||||
make_union_table_name(table_name_buffer);
|
||||
writer->add_member("table_name").add_str(table_name_buffer);
|
||||
writer->add_member("access_type").add_str("ALL"); // not very useful
|
||||
@ -589,7 +590,8 @@ void Explain_union::print_explain_json(Explain_query *query,
|
||||
/* r_loops (not present in tabular output) */
|
||||
if (is_analyze)
|
||||
{
|
||||
writer->add_member("r_loops").add_ll(fake_select_lex_tracker.get_loops());
|
||||
writer->add_member("r_loops").add_ll(
|
||||
fake_select_lex_tracker.get_loops());
|
||||
}
|
||||
|
||||
/* `r_rows` */
|
||||
@ -601,7 +603,7 @@ void Explain_union::print_explain_json(Explain_query *query,
|
||||
else
|
||||
writer->add_null();
|
||||
}
|
||||
|
||||
}
|
||||
writer->add_member("query_specifications").start_array();
|
||||
|
||||
for (int i= 0; i < (int) union_members.elements(); i++)
|
||||
|
Reference in New Issue
Block a user