config root man

Current Path : /home/usr.opt/mysql57/mysql-test/r/

FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64
Upload File :
Current File : /home/usr.opt/mysql57/mysql-test/r/explain_other.result

# WL#6369: EXPLAIN for other query
CREATE DATABASE mysqltest1;
USE mysqltest1;
CREATE TABLE t1 (f1 int);
INSERT INTO t1 VALUES (1),(2);
ERROR HY000: This command is not supported in the prepared statement protocol yet
Test error throwing
EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'EXPLAIN SELECT f1 FROM t1'
ERROR HY000: EXPLAIN FOR CONNECTION command is supported only for SELECT/UPDATE/INSERT/DELETE/REPLACE
EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SHOW FIELDS IN t1'
ERROR HY000: EXPLAIN FOR CONNECTION command is supported only for SELECT/UPDATE/INSERT/DELETE/REPLACE
PREPARE stmt FROM 'EXPLAIN FOR CONNECTION 1';
ERROR HY000: This command is not supported in the prepared statement protocol yet
PREPARE stmt FROM 'SELECT * FROM t1';
EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'EXECUTE stmt'
ERROR HY000: EXPLAIN FOR CONNECTION command is supported only for SELECT/UPDATE/INSERT/DELETE/REPLACE
CREATE PROCEDURE proc6369()
EXPLAIN FOR CONNECTION 1;
ERROR 42000: This version of MySQL doesn't yet support 'non-standalone EXPLAIN FOR CONNECTION'
CREATE PROCEDURE proc6369()
SELECT * FROM t1;
EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'CALL proc6369()'
ERROR HY000: EXPLAIN FOR CONNECTION command is supported only for SELECT/UPDATE/INSERT/DELETE/REPLACE
DROP PROCEDURE proc6369;
ERROR HY000: EXPLAIN FOR CONNECTION command is supported only for SELECT/UPDATE/INSERT/DELETE/REPLACE
EXPLAIN FOR CONNECTION 11111111;
ERROR HY000: Unknown thread id: 11111111
Explain queries with ready plan
EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT f1 FROM t1'
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ALL	NULL	NULL	NULL	NULL	2	100.00	NULL
EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT * FROM (SELECT * FROM t1) tt'
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ALL	NULL	NULL	NULL	NULL	2	100.00	NULL
EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT * FROM t1 WHERE f1 IN (SELECT * FROM t1)'
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ALL	NULL	NULL	NULL	NULL	2	100.00	NULL
1	SIMPLE	t1	NULL	ALL	NULL	NULL	NULL	NULL	2	50.00	Using where; FirstMatch(t1); Using join buffer (Block Nested Loop)
EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT * FROM t1 UNION ALL SELECT * FROM t1 ORDER BY 1'
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	PRIMARY	t1	NULL	ALL	NULL	NULL	NULL	NULL	2	100.00	NULL
2	UNION	t1	NULL	ALL	NULL	NULL	NULL	NULL	2	100.00	NULL
NULL	UNION RESULT	<union1,2>	NULL	ALL	NULL	NULL	NULL	NULL	NULL	NULL	Using temporary; Using filesort
EXPLAIN FORMAT=JSON FOR QUERY 'SELECT f1 FROM t1'
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "1.40"
    },
    "table": {
      "table_name": "t1",
      "access_type": "ALL",
      "rows_examined_per_scan": 2,
      "rows_produced_per_join": 2,
      "filtered": "100.00",
      "cost_info": {
        "read_cost": "1.00",
        "eval_cost": "0.40",
        "prefix_cost": "1.40",
        "data_read_per_join": "16"
      },
      "used_columns": [
        "f1"
      ]
    }
  }
}
EXPLAIN FORMAT=JSON FOR QUERY 'SELECT * FROM (SELECT * FROM t1) tt'
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "1.40"
    },
    "table": {
      "table_name": "t1",
      "access_type": "ALL",
      "rows_examined_per_scan": 2,
      "rows_produced_per_join": 2,
      "filtered": "100.00",
      "cost_info": {
        "read_cost": "1.00",
        "eval_cost": "0.40",
        "prefix_cost": "1.40",
        "data_read_per_join": "16"
      },
      "used_columns": [
        "f1"
      ]
    }
  }
}
EXPLAIN FORMAT=JSON FOR QUERY 'SELECT * FROM t1 WHERE f1 IN (SELECT * FROM t1)'
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "3.20"
    },
    "nested_loop": [
      {
        "table": {
          "table_name": "t1",
          "access_type": "ALL",
          "rows_examined_per_scan": 2,
          "rows_produced_per_join": 2,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "1.00",
            "eval_cost": "0.40",
            "prefix_cost": "1.40",
            "data_read_per_join": "16"
          },
          "used_columns": [
            "f1"
          ]
        }
      },
      {
        "table": {
          "table_name": "t1",
          "access_type": "ALL",
          "rows_examined_per_scan": 2,
          "rows_produced_per_join": 2,
          "filtered": "50.00",
          "using_where": true,
          "first_match": "t1",
          "using_join_buffer": "Block Nested Loop",
          "cost_info": {
            "read_cost": "1.00",
            "eval_cost": "0.40",
            "prefix_cost": "3.20",
            "data_read_per_join": "16"
          },
          "used_columns": [
            "f1"
          ]
        }
      }
    ]
  }
}
EXPLAIN FORMAT=JSON FOR QUERY 'SELECT * FROM t1 UNION ALL SELECT * FROM t1 ORDER BY 1'
EXPLAIN
{
  "query_block": {
    "union_result": {
      "using_temporary_table": true,
      "table_name": "<union1,2>",
      "access_type": "ALL",
      "query_specifications": [
        {
          "dependent": false,
          "cacheable": true,
          "query_block": {
            "select_id": 1,
            "cost_info": {
              "query_cost": "1.40"
            },
            "table": {
              "table_name": "t1",
              "access_type": "ALL",
              "rows_examined_per_scan": 2,
              "rows_produced_per_join": 2,
              "filtered": "100.00",
              "cost_info": {
                "read_cost": "1.00",
                "eval_cost": "0.40",
                "prefix_cost": "1.40",
                "data_read_per_join": "16"
              },
              "used_columns": [
                "f1"
              ]
            }
          }
        },
        {
          "dependent": false,
          "cacheable": true,
          "query_block": {
            "select_id": 2,
            "cost_info": {
              "query_cost": "1.40"
            },
            "table": {
              "table_name": "t1",
              "access_type": "ALL",
              "rows_examined_per_scan": 2,
              "rows_produced_per_join": 2,
              "filtered": "100.00",
              "cost_info": {
                "read_cost": "1.00",
                "eval_cost": "0.40",
                "prefix_cost": "1.40",
                "data_read_per_join": "16"
              },
              "used_columns": [
                "f1"
              ]
            }
          }
        }
      ]
    }
  }
}
EXPLAIN FORMAT=JSON FOR QUERY 'SELECT * FROM t1 WHERE 1=0'
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "message": "Impossible WHERE"
  }
}
EXPLAIN FORMAT=JSON FOR QUERY 'SELECT * FROM t1
GROUP BY f1 NOT IN
(SELECT f1+10 AS f2 FROM t1 AS t2
GROUP BY f2 NOT IN
(SELECT f1+100 AS f3 FROM t1 AS t3))'
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "3.40"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "2.00"
      },
      "table": {
        "table_name": "t1",
        "access_type": "ALL",
        "rows_examined_per_scan": 2,
        "rows_produced_per_join": 2,
        "filtered": "100.00",
        "cost_info": {
          "read_cost": "1.00",
          "eval_cost": "0.40",
          "prefix_cost": "1.40",
          "data_read_per_join": "16"
        },
        "used_columns": [
          "f1"
        ]
      },
      "group_by_subqueries": [
        {
          "dependent": true,
          "cacheable": false,
          "query_block": {
            "select_id": 2,
            "cost_info": {
              "query_cost": "1.40"
            },
            "table": {
              "table_name": "t2",
              "access_type": "ALL",
              "rows_examined_per_scan": 2,
              "rows_produced_per_join": 2,
              "filtered": "100.00",
              "using_where": true,
              "cost_info": {
                "read_cost": "1.00",
                "eval_cost": "0.40",
                "prefix_cost": "1.40",
                "data_read_per_join": "16"
              },
              "used_columns": [
                "f1"
              ]
            }
          }
        }
      ]
    }
  }
}
Explain for non-select queries
EXPLAIN FORMAT=JSON FOR QUERY 'INSERT INTO t1 VALUES (3)'
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "table": {
      "insert": true,
      "table_name": "t1",
      "access_type": "ALL"
    }
  }
}
EXPLAIN FORMAT=JSON FOR QUERY 'INSERT INTO t1 SELECT 4'
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "table": {
      "insert": true,
      "table_name": "t1",
      "access_type": "ALL"
    }
  }
}
EXPLAIN FORMAT=JSON FOR QUERY 'INSERT INTO t1 SELECT f1 + 4 FROM t1'
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "1.80"
    },
    "table": {
      "insert": true,
      "select_id": 1,
      "table_name": "t1",
      "access_type": "ALL"
    },
    "insert_from": {
      "buffer_result": {
        "using_temporary_table": true,
        "table": {
          "table_name": "t1",
          "access_type": "ALL",
          "rows_examined_per_scan": 4,
          "rows_produced_per_join": 4,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "1.00",
            "eval_cost": "0.80",
            "prefix_cost": "1.80",
            "data_read_per_join": "32"
          },
          "used_columns": [
            "f1"
          ]
        }
      }
    }
  }
}
EXPLAIN FORMAT=JSON FOR QUERY 'UPDATE t1 SET f1=4 WHERE f1=4'
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "message": "Plan isn't ready yet"
  }
}
EXPLAIN FORMAT=JSON FOR QUERY 'UPDATE t1 SET f1=4 WHERE f1=4'
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "table": {
      "update": true,
      "table_name": "t1",
      "access_type": "ALL",
      "rows_examined_per_scan": 8,
      "filtered": "100.00",
      "using_where": true
    }
  }
}
CREATE TABLE t2 (f2 int);
EXPLAIN FORMAT=JSON FOR QUERY 'UPDATE t1 SET f1=f1+0
ORDER BY f1 NOT IN
(SELECT f1+10 AS f2 FROM t2
GROUP BY f2 NOT IN
(SELECT f1+100 AS f3 FROM t2 AS t3))'
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "ordering_operation": {
      "using_filesort": true,
      "table": {
        "update": true,
        "table_name": "t1",
        "access_type": "ALL",
        "rows_examined_per_scan": 8,
        "filtered": "100.00"
      },
      "order_by_subqueries": [
        {
          "dependent": false,
          "cacheable": true,
          "query_block": {
            "select_id": 2,
            "message": "Plan isn't ready yet"
          }
        }
      ]
    }
  }
}
CREATE VIEW v1 AS SELECT t1.f1 FROM t1 JOIN t1 tt on t1.f1=tt.f1;
EXPLAIN FORMAT=JSON FOR QUERY 'UPDATE v1 SET f1=5 WHERE f1=5'
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "5.20"
    },
    "nested_loop": [
      {
        "table": {
          "update": true,
          "table_name": "t1",
          "access_type": "ALL",
          "rows_examined_per_scan": 8,
          "rows_produced_per_join": 1,
          "filtered": "12.50",
          "using_where": true,
          "cost_info": {
            "read_cost": "2.40",
            "eval_cost": "0.20",
            "prefix_cost": "2.60",
            "data_read_per_join": "8"
          },
          "used_columns": [
            "f1"
          ]
        }
      },
      {
        "table": {
          "table_name": "tt",
          "access_type": "ALL",
          "rows_examined_per_scan": 8,
          "rows_produced_per_join": 1,
          "filtered": "12.50",
          "using_where": true,
          "cost_info": {
            "read_cost": "2.40",
            "eval_cost": "0.20",
            "prefix_cost": "5.20",
            "data_read_per_join": "8"
          },
          "used_columns": [
            "f1"
          ]
        }
      }
    ]
  }
}
EXPLAIN FORMAT=JSON FOR QUERY 'DELETE FROM t1 WHERE f1=4'
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "table": {
      "delete": true,
      "table_name": "t1",
      "access_type": "ALL",
      "rows_examined_per_scan": 8,
      "filtered": "100.00",
      "using_where": true
    }
  }
}
EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'INSERT INTO t1 VALUES (3)'
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	INSERT	t1	NULL	ALL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'INSERT INTO t1 SELECT 4'
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	INSERT	t1	NULL	ALL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'INSERT INTO t1 SELECT f1 + 4 FROM t1'
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	INSERT	t1	NULL	ALL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
1	SIMPLE	t1	NULL	ALL	NULL	NULL	NULL	NULL	9	100.00	Using temporary
EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'UPDATE t1 SET f1=4 WHERE f1=4'
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	UPDATE	t1	NULL	ALL	NULL	NULL	NULL	NULL	18	100.00	Using where
EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'UPDATE v1 SET f1=5 WHERE f1=5'
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	UPDATE	t1	NULL	ALL	NULL	NULL	NULL	NULL	18	10.00	Using where
1	SIMPLE	tt	NULL	ALL	NULL	NULL	NULL	NULL	18	10.00	Using where
EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'DELETE FROM t1 WHERE f1=4'
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	DELETE	t1	NULL	ALL	NULL	NULL	NULL	NULL	18	100.00	Using where
Explain queries with plan only partially ready
EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT * FROM (SELECT * FROM t1 GROUP BY 1) tt'
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Plan isn't ready yet
2	DERIVED	t1	NULL	ALL	NULL	NULL	NULL	NULL	17	100.00	Using temporary; Using filesort
EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT * FROM t1 UNION ALL SELECT * FROM t1 ORDER BY
(SELECT * FROM t1 LIMIT 1)'
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	PRIMARY	t1	NULL	ALL	NULL	NULL	NULL	NULL	17	100.00	NULL
2	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Plan isn't ready yet
NULL	UNION RESULT	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Plan isn't ready yet
3	SUBQUERY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Plan isn't ready yet
EXPLAIN FORMAT=JSON FOR QUERY 'SELECT * FROM (SELECT * FROM t1 GROUP BY 1) tt'
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "message": "Plan isn't ready yet",
    "table": {
      "materialized_from_subquery": {
        "using_temporary_table": true,
        "dependent": false,
        "cacheable": true,
        "query_block": {
          "select_id": 2,
          "cost_info": {
            "query_cost": "21.40"
          },
          "grouping_operation": {
            "using_temporary_table": true,
            "using_filesort": true,
            "cost_info": {
              "sort_cost": "17.00"
            },
            "table": {
              "table_name": "t1",
              "access_type": "ALL",
              "rows_examined_per_scan": 17,
              "rows_produced_per_join": 17,
              "filtered": "100.00",
              "cost_info": {
                "read_cost": "1.00",
                "eval_cost": "3.40",
                "prefix_cost": "4.40",
                "data_read_per_join": "136"
              },
              "used_columns": [
                "f1"
              ]
            }
          }
        }
      }
    }
  }
}
EXPLAIN FORMAT=JSON FOR QUERY 'SELECT * FROM t1 UNION ALL SELECT * FROM t1 ORDER BY
(SELECT * FROM t1 LIMIT 1)'
EXPLAIN
{
  "query_block": {
    "ordering_operation": {
      "using_filesort": true,
      "union_result": {
        "using_temporary_table": true,
        "message": "Plan isn't ready yet",
        "query_specifications": [
          {
            "dependent": false,
            "cacheable": true,
            "query_block": {
              "select_id": 1,
              "cost_info": {
                "query_cost": "4.40"
              },
              "table": {
                "table_name": "t1",
                "access_type": "ALL",
                "rows_examined_per_scan": 17,
                "rows_produced_per_join": 17,
                "filtered": "100.00",
                "cost_info": {
                  "read_cost": "1.00",
                  "eval_cost": "3.40",
                  "prefix_cost": "4.40",
                  "data_read_per_join": "136"
                },
                "used_columns": [
                  "f1"
                ]
              }
            }
          },
          {
            "dependent": false,
            "cacheable": true,
            "query_block": {
              "select_id": 2,
              "message": "Plan isn't ready yet"
            }
          }
        ]
      },
      "order_by_subqueries": [
        {
          "dependent": false,
          "cacheable": true,
          "query_block": {
            "select_id": 3,
            "message": "Plan isn't ready yet"
          }
        }
      ]
    }
  }
}
Ensure materialized derived still has plans after materialization
set @optimizer_switch_saved= @@optimizer_switch;
set optimizer_switch='derived_merge=off';
EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT * FROM (SELECT * FROM t1) tt'
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	PRIMARY	<derived2>	NULL	ALL	NULL	NULL	NULL	NULL	17	100.00	NULL
2	DERIVED	t1	NULL	ALL	NULL	NULL	NULL	NULL	17	100.00	NULL
EXPLAIN FORMAT=JSON FOR QUERY 'SELECT * FROM (SELECT * FROM t1) tt'
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "14.25"
    },
    "table": {
      "table_name": "tt",
      "access_type": "ALL",
      "rows_examined_per_scan": 17,
      "rows_produced_per_join": 17,
      "filtered": "100.00",
      "cost_info": {
        "read_cost": "10.85",
        "eval_cost": "3.40",
        "prefix_cost": "14.25",
        "data_read_per_join": "272"
      },
      "used_columns": [
        "f1"
      ],
      "materialized_from_subquery": {
        "using_temporary_table": true,
        "dependent": false,
        "cacheable": true,
        "query_block": {
          "select_id": 2,
          "cost_info": {
            "query_cost": "4.40"
          },
          "table": {
            "table_name": "t1",
            "access_type": "ALL",
            "rows_examined_per_scan": 17,
            "rows_produced_per_join": 17,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "1.00",
              "eval_cost": "3.40",
              "prefix_cost": "4.40",
              "data_read_per_join": "136"
            },
            "used_columns": [
              "f1"
            ]
          }
        }
      }
    }
  }
}
set optimizer_switch= @optimizer_switch_saved;
WHERE subqueries, neither parent query nor subquery has plan
EXPLAIN FORMAT=JSON FOR QUERY 'SELECT t2.f1 FROM t1 STRAIGHT_JOIN t1 AS t2
WHERE t1.f1>(SELECT t3.f1 FROM t1 AS t3 LIMIT 1)'
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "message": "Plan isn't ready yet",
    "attached_subqueries": [
      {
        "dependent": false,
        "cacheable": true,
        "query_block": {
          "select_id": 2,
          "message": "Plan isn't ready yet"
        }
      }
    ]
  }
}
the same, parent query has a plan
EXPLAIN FORMAT=JSON FOR QUERY 'SELECT t2.f1 FROM t1 STRAIGHT_JOIN t1 AS t2
WHERE t1.f1>(SELECT t3.f1 FROM t1 AS t3 LIMIT 1)'
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "24.66"
    },
    "nested_loop": [
      {
        "table": {
          "table_name": "t1",
          "access_type": "ALL",
          "rows_examined_per_scan": 17,
          "rows_produced_per_join": 5,
          "filtered": "33.33",
          "using_where": true,
          "cost_info": {
            "read_cost": "3.27",
            "eval_cost": "1.13",
            "prefix_cost": "4.40",
            "data_read_per_join": "45"
          },
          "used_columns": [
            "f1"
          ],
          "attached_subqueries": [
            {
              "dependent": false,
              "cacheable": true,
              "query_block": {
                "select_id": 2,
                "message": "Plan isn't ready yet"
              }
            }
          ]
        }
      },
      {
        "table": {
          "table_name": "t2",
          "access_type": "ALL",
          "rows_examined_per_scan": 17,
          "rows_produced_per_join": 96,
          "filtered": "100.00",
          "using_join_buffer": "Block Nested Loop",
          "cost_info": {
            "read_cost": "1.00",
            "eval_cost": "19.26",
            "prefix_cost": "24.66",
            "data_read_per_join": "770"
          },
          "used_columns": [
            "f1"
          ]
        }
      }
    ]
  }
}
the same, both have a plan
EXPLAIN FORMAT=JSON FOR QUERY 'SELECT t2.f1 FROM t1 STRAIGHT_JOIN t1 AS t2
WHERE t1.f1>(SELECT t3.f1 FROM t1 AS t3 LIMIT 1)'
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "24.66"
    },
    "nested_loop": [
      {
        "table": {
          "table_name": "t1",
          "access_type": "ALL",
          "rows_examined_per_scan": 17,
          "rows_produced_per_join": 5,
          "filtered": "33.33",
          "using_where": true,
          "cost_info": {
            "read_cost": "3.27",
            "eval_cost": "1.13",
            "prefix_cost": "4.40",
            "data_read_per_join": "45"
          },
          "used_columns": [
            "f1"
          ],
          "attached_subqueries": [
            {
              "dependent": false,
              "cacheable": true,
              "query_block": {
                "select_id": 2,
                "cost_info": {
                  "query_cost": "4.40"
                },
                "table": {
                  "table_name": "t3",
                  "access_type": "ALL",
                  "rows_examined_per_scan": 17,
                  "rows_produced_per_join": 17,
                  "filtered": "100.00",
                  "cost_info": {
                    "read_cost": "1.00",
                    "eval_cost": "3.40",
                    "prefix_cost": "4.40",
                    "data_read_per_join": "136"
                  },
                  "used_columns": [
                    "f1"
                  ]
                }
              }
            }
          ]
        }
      },
      {
        "table": {
          "table_name": "t2",
          "access_type": "ALL",
          "rows_examined_per_scan": 17,
          "rows_produced_per_join": 96,
          "filtered": "100.00",
          "using_join_buffer": "Block Nested Loop",
          "cost_info": {
            "read_cost": "1.00",
            "eval_cost": "19.26",
            "prefix_cost": "24.66",
            "data_read_per_join": "770"
          },
          "used_columns": [
            "f1"
          ]
        }
      }
    ]
  }
}
To be compared with regular EXPLAIN:
EXPLAIN FORMAT=JSON SELECT t2.f1 FROM t1 STRAIGHT_JOIN t1 AS t2
WHERE t1.f1>(SELECT t3.f1 FROM t1 AS t3 LIMIT 1);
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "24.66"
    },
    "nested_loop": [
      {
        "table": {
          "table_name": "t1",
          "access_type": "ALL",
          "rows_examined_per_scan": 17,
          "rows_produced_per_join": 5,
          "filtered": "33.33",
          "cost_info": {
            "read_cost": "3.27",
            "eval_cost": "1.13",
            "prefix_cost": "4.40",
            "data_read_per_join": "45"
          },
          "used_columns": [
            "f1"
          ],
          "attached_condition": "(`mysqltest1`.`t1`.`f1` > (/* select#2 */ select `mysqltest1`.`t3`.`f1` from `mysqltest1`.`t1` `t3` limit 1))",
          "attached_subqueries": [
            {
              "dependent": false,
              "cacheable": true,
              "query_block": {
                "select_id": 2,
                "cost_info": {
                  "query_cost": "4.40"
                },
                "table": {
                  "table_name": "t3",
                  "access_type": "ALL",
                  "rows_examined_per_scan": 17,
                  "rows_produced_per_join": 17,
                  "filtered": "100.00",
                  "cost_info": {
                    "read_cost": "1.00",
                    "eval_cost": "3.40",
                    "prefix_cost": "4.40",
                    "data_read_per_join": "136"
                  },
                  "used_columns": [
                    "f1"
                  ]
                }
              }
            }
          ]
        }
      },
      {
        "table": {
          "table_name": "t2",
          "access_type": "ALL",
          "rows_examined_per_scan": 17,
          "rows_produced_per_join": 96,
          "filtered": "100.00",
          "using_join_buffer": "Block Nested Loop",
          "cost_info": {
            "read_cost": "1.00",
            "eval_cost": "19.26",
            "prefix_cost": "24.66",
            "data_read_per_join": "770"
          },
          "used_columns": [
            "f1"
          ]
        }
      }
    ]
  }
}
Warnings:
Note	1003	/* select#1 */ select `t2`.`f1` AS `f1` from `mysqltest1`.`t1` straight_join `mysqltest1`.`t1` `t2` where (`mysqltest1`.`t1`.`f1` > (/* select#2 */ select `mysqltest1`.`t3`.`f1` from `mysqltest1`.`t1` `t3` limit 1))
EXPLAIN FORMAT=JSON FOR QUERY 'SELECT 1 FROM t1 WHERE
ROW(f1,f1) >= ROW('1', (SELECT 1 FROM t1 WHERE f1 > 1234))'
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "4.40"
    },
    "table": {
      "table_name": "t1",
      "access_type": "ALL",
      "rows_examined_per_scan": 17,
      "rows_produced_per_join": 17,
      "filtered": "100.00",
      "using_where": true,
      "cost_info": {
        "read_cost": "1.00",
        "eval_cost": "3.40",
        "prefix_cost": "4.40",
        "data_read_per_join": "136"
      },
      "used_columns": [
        "f1"
      ]
    },
    "optimized_away_subqueries": [
      {
        "dependent": false,
        "cacheable": true,
        "query_block": {
          "select_id": 2,
          "cost_info": {
            "query_cost": "4.40"
          },
          "table": {
            "table_name": "t1",
            "access_type": "ALL",
            "rows_examined_per_scan": 17,
            "rows_produced_per_join": 5,
            "filtered": "33.33",
            "using_where": true,
            "cost_info": {
              "read_cost": "3.27",
              "eval_cost": "1.13",
              "prefix_cost": "4.40",
              "data_read_per_join": "45"
            },
            "used_columns": [
              "f1"
            ]
          }
        }
      }
    ]
  }
}
EXPLAIN FORMAT=JSON SELECT 1 FROM t1 WHERE
ROW(f1,f1) >= ROW('1', (SELECT 1 FROM t1 WHERE f1 > 1234));
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "4.40"
    },
    "table": {
      "table_name": "t1",
      "access_type": "ALL",
      "rows_examined_per_scan": 17,
      "rows_produced_per_join": 17,
      "filtered": "100.00",
      "cost_info": {
        "read_cost": "1.00",
        "eval_cost": "3.40",
        "prefix_cost": "4.40",
        "data_read_per_join": "136"
      },
      "used_columns": [
        "f1"
      ],
      "attached_condition": "((`mysqltest1`.`t1`.`f1`,`mysqltest1`.`t1`.`f1`) >= <cache>(('1',(/* select#2 */ select 1 from `mysqltest1`.`t1` where (`t1`.`f1` > 1234)))))"
    },
    "optimized_away_subqueries": [
      {
        "dependent": false,
        "cacheable": true,
        "query_block": {
          "select_id": 2,
          "cost_info": {
            "query_cost": "4.40"
          },
          "table": {
            "table_name": "t1",
            "access_type": "ALL",
            "rows_examined_per_scan": 17,
            "rows_produced_per_join": 5,
            "filtered": "33.33",
            "cost_info": {
              "read_cost": "3.27",
              "eval_cost": "1.13",
              "prefix_cost": "4.40",
              "data_read_per_join": "45"
            },
            "used_columns": [
              "f1"
            ],
            "attached_condition": "(`t1`.`f1` > 1234)"
          }
        }
      }
    ]
  }
}
Warnings:
Note	1003	/* select#1 */ select 1 AS `1` from `mysqltest1`.`t1` where ((`mysqltest1`.`t1`.`f1`,`mysqltest1`.`t1`.`f1`) >= <cache>(('1',(/* select#2 */ select 1 from `mysqltest1`.`t1` where (`t1`.`f1` > 1234)))))
CREATE TABLE t3 (pk INT PRIMARY KEY);
INSERT INTO t3 SELECT DISTINCT * FROM t1;
EXPLAIN FORMAT=JSON FOR QUERY 'SELECT * FROM t3 WHERE pk=(SELECT f1 FROM t1 limit 1)'
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "1.00"
    },
    "table": {
      "table_name": "t3",
      "access_type": "const",
      "possible_keys": [
        "PRIMARY"
      ],
      "key": "PRIMARY",
      "used_key_parts": [
        "pk"
      ],
      "key_length": "4",
      "ref": [
        "const"
      ],
      "rows_examined_per_scan": 1,
      "rows_produced_per_join": 1,
      "filtered": "100.00",
      "using_index": true,
      "cost_info": {
        "read_cost": "0.00",
        "eval_cost": "0.20",
        "prefix_cost": "0.00",
        "data_read_per_join": "8"
      },
      "used_columns": [
        "pk"
      ]
    },
    "optimized_away_subqueries": [
      {
        "dependent": false,
        "cacheable": true,
        "query_block": {
          "select_id": 2,
          "cost_info": {
            "query_cost": "4.40"
          },
          "table": {
            "table_name": "t1",
            "access_type": "ALL",
            "rows_examined_per_scan": 17,
            "rows_produced_per_join": 17,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "1.00",
              "eval_cost": "3.40",
              "prefix_cost": "4.40",
              "data_read_per_join": "136"
            },
            "used_columns": [
              "f1"
            ]
          }
        }
      }
    ]
  }
}
# Check access rights checking
set @orig_sql_mode = @@sql_mode;
set sql_mode=(select replace(@@sql_mode,'NO_AUTO_CREATE_USER',''));
Warnings:
Warning	3090	Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release.
GRANT USAGE ON *.* TO 'privtest'@'localhost';
Warnings:
Warning	1287	Using GRANT for creating new user is deprecated and will be removed in future release. Create new user with CREATE USER statement.
set sql_mode= @orig_sql_mode;
Warnings:
Warning	3090	Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release.
GRANT SUPER ON *.* TO 'privtest'@'localhost';
GRANT SELECT ON mysqltest1.t2 TO 'privtest'@'localhost';
CREATE VIEW v2 AS SELECT * FROM t2;
GRANT SELECT,INSERT,UPDATE ON mysqltest1.v2 TO 'privtest'@'localhost';
EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT f1 FROM t1'
ERROR 28000: Access denied for user 'privtest'@'localhost' (using password: NO)
SELECT f2 FROM v2;
f2
EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT f2 FROM v2'
ERROR 28000: Access denied for user 'privtest'@'localhost' (using password: NO)
UPDATE v2 SET f2=1;
EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'UPDATE v2 SET f2=1'
ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
INSERT INTO v2 VALUES(1);
EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'INSERT INTO v2 VALUES(1)'
ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
INSERT INTO v2 SELECT 3 FROM t2;
EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'INSERT INTO v2 SELECT 3 FROM t2'
ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
SELECT f2 FROM v2;
f2
1
1
3
3
3
3
3
3
EXPLAIN SELECT f2 FROM v2;
ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
DROP USER 'privtest'@localhost;
DROP VIEW v1, v2;
DROP TABLE t1, t2, t3;
#
# Bug#14586538: EXPLAIN OTHER RESULT NOT MATCHING WITH EXPLAIN
#
CREATE TABLE h2 (
pk int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (pk)
) ENGINE=MyISAM AUTO_INCREMENT=10 DEFAULT CHARSET=latin1;
insert into h2 values (1),(2),(3),(4),(5),(6),(7),(8),(9);
CREATE TABLE aa3 (
col_int_key int(11) DEFAULT NULL,
KEY col_int_key (col_int_key)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
EXPLAIN SELECT alias1.pk AS field1 FROM h2 AS alias1 LEFT JOIN aa3 AS alias2 ON  alias1.pk =  alias2.col_int_key WHERE alias1.pk <> 9 GROUP BY field1 ORDER BY field1 LIMIT 1 OFFSET 3;;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	alias1	NULL	index	PRIMARY	PRIMARY	4	NULL	4	100.00	Using where; Using index
1	SIMPLE	alias2	NULL	ref	col_int_key	col_int_key	5	mysqltest1.alias1.pk	1	100.00	Using index
Warnings:
Note	1003	/* select#1 */ select `mysqltest1`.`alias1`.`pk` AS `field1` from `mysqltest1`.`h2` `alias1` left join `mysqltest1`.`aa3` `alias2` on((`mysqltest1`.`alias2`.`col_int_key` = `mysqltest1`.`alias1`.`pk`)) where (`mysqltest1`.`alias1`.`pk` <> 9) group by `field1` order by `field1` limit 3,1
Should show same # of rows as above
EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT alias1.pk AS field1 FROM h2 AS alias1 LEFT JOIN aa3 AS alias2 ON  alias1.pk =  alias2.col_int_key WHERE alias1.pk <> 9 GROUP BY field1 ORDER BY field1 LIMIT 1 OFFSET 3'
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	alias1	NULL	index	PRIMARY	PRIMARY	4	NULL	4	100.00	Using where; Using index
1	SIMPLE	alias2	NULL	ref	col_int_key	col_int_key	5	mysqltest1.alias1.pk	1	100.00	Using index
DROP TABLE h2, aa3;
#
# Bug#14591376: EXPLAIN OTHER RESULT NOT MATCHING WITH EXPLAIN - REF
#
CREATE TABLE t1 (
pk int(11),
col_int_key int(11) DEFAULT NULL,
KEY col_int_key (col_int_key)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO t1 VALUES (NULL,NULL);
INSERT INTO t1 VALUES (6,NULL);
INSERT INTO t1 VALUES (8,-1131610112);
INSERT INTO t1 VALUES (2,-1009057792);
INSERT INTO t1 VALUES (-1220345856,1);
INSERT INTO t1 VALUES (NULL,-185204736);
EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT pk FROM t1 WHERE col_int_key= 8'
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ref	col_int_key	col_int_key	5	const	1	100.00	NULL
DROP TABLE t1;
# From Bug#14463247 MYSQL CRASHES ON THE QUERY
#
CREATE TABLE tbl1 (
login int(11) NOT NULL,
numb decimal(15,2) NOT NULL DEFAULT '0.00',
PRIMARY KEY (login),
KEY numb (numb)
)  ;
CREATE TABLE tbl2 (
login int(11) NOT NULL,
cmd tinyint(4) NOT NULL,
nump decimal(15,2) NOT NULL DEFAULT '0.00',
KEY cmd (cmd),
KEY login (login)
) ;
insert into tbl1 (login) values(1),(2);
insert ignore into tbl2 (login) values(1),(2);
Warnings:
Warning	1364	Field 'cmd' doesn't have a default value
EXPLAIN FORMAT=TRADITIONAL FOR QUERY 'SELECT 
t1.login AS tlogin, 
numb - 
IFNULL((SELECT sum(nump) FROM tbl2 WHERE login=t1.login), 0) -
IFNULL((SELECT sum(nump) FROM tbl2 WHERE login=t1.login), 0) as sp
FROM tbl1 t1, tbl2 t2 
WHERE t1.login=t2.login 
GROUP BY t1.login 
ORDER BY numb - IFNULL((SELECT sum(nump) FROM tbl2 WHERE login=t1.login), 0)
- IFNULL((SELECT sum(nump) FROM tbl2 WHERE login=t1.login), 0)
'
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	PRIMARY	t1	NULL	index	PRIMARY,numb	PRIMARY	4	NULL	2	100.00	Using temporary; Using filesort
1	PRIMARY	t2	NULL	ref	login	login	4	mysqltest1.t1.login	1	100.00	Using index
3	DEPENDENT SUBQUERY	tbl2	NULL	ref	login	login	4	func	1	100.00	NULL
2	DEPENDENT SUBQUERY	tbl2	NULL	ref	login	login	4	func	1	100.00	NULL
EXPLAIN FORMAT=JSON FOR QUERY 'SELECT 
t1.login AS tlogin, 
numb - 
IFNULL((SELECT sum(nump) FROM tbl2 WHERE login=t1.login), 0) -
IFNULL((SELECT sum(nump) FROM tbl2 WHERE login=t1.login), 0) as sp
FROM tbl1 t1, tbl2 t2 
WHERE t1.login=t2.login 
GROUP BY t1.login 
ORDER BY numb - IFNULL((SELECT sum(nump) FROM tbl2 WHERE login=t1.login), 0)
- IFNULL((SELECT sum(nump) FROM tbl2 WHERE login=t1.login), 0)
'
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "3.80"
    },
    "ordering_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "grouping_operation": {
        "using_filesort": false,
        "nested_loop": [
          {
            "table": {
              "table_name": "t1",
              "access_type": "index",
              "possible_keys": [
                "PRIMARY",
                "numb"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "login"
              ],
              "key_length": "4",
              "rows_examined_per_scan": 2,
              "rows_produced_per_join": 2,
              "filtered": "100.00",
              "cost_info": {
                "read_cost": "1.00",
                "eval_cost": "0.40",
                "prefix_cost": "1.40",
                "data_read_per_join": "32"
              },
              "used_columns": [
                "login",
                "numb"
              ]
            }
          },
          {
            "table": {
              "table_name": "t2",
              "access_type": "ref",
              "possible_keys": [
                "login"
              ],
              "key": "login",
              "used_key_parts": [
                "login"
              ],
              "key_length": "4",
              "ref": [
                "mysqltest1.t1.login"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 2,
              "filtered": "100.00",
              "using_index": true,
              "cost_info": {
                "read_cost": "2.00",
                "eval_cost": "0.40",
                "prefix_cost": "3.80",
                "data_read_per_join": "32"
              },
              "used_columns": [
                "login"
              ]
            }
          }
        ],
        "select_list_subqueries": [
          {
            "dependent": true,
            "cacheable": false,
            "query_block": {
              "select_id": 3,
              "cost_info": {
                "query_cost": "1.20"
              },
              "table": {
                "table_name": "tbl2",
                "access_type": "ref",
                "possible_keys": [
                  "login"
                ],
                "key": "login",
                "used_key_parts": [
                  "login"
                ],
                "key_length": "4",
                "ref": [
                  "func"
                ],
                "rows_examined_per_scan": 1,
                "rows_produced_per_join": 1,
                "filtered": "100.00",
                "cost_info": {
                  "read_cost": "1.00",
                  "eval_cost": "0.20",
                  "prefix_cost": "1.20",
                  "data_read_per_join": "16"
                },
                "used_columns": [
                  "login",
                  "nump"
                ]
              }
            }
          },
          {
            "dependent": true,
            "cacheable": false,
            "query_block": {
              "select_id": 2,
              "cost_info": {
                "query_cost": "1.20"
              },
              "table": {
                "table_name": "tbl2",
                "access_type": "ref",
                "possible_keys": [
                  "login"
                ],
                "key": "login",
                "used_key_parts": [
                  "login"
                ],
                "key_length": "4",
                "ref": [
                  "func"
                ],
                "rows_examined_per_scan": 1,
                "rows_produced_per_join": 1,
                "filtered": "100.00",
                "cost_info": {
                  "read_cost": "1.00",
                  "eval_cost": "0.20",
                  "prefix_cost": "1.20",
                  "data_read_per_join": "16"
                },
                "used_columns": [
                  "login",
                  "nump"
                ]
              }
            }
          }
        ]
      }
    }
  }
}
DROP TABLE tbl1, tbl2;
# End of tests for WL#6369
#
# Bug#19822146 EXPLAIN FOR CONNECTION CRASHES IN 
#              EXPLAIN_JOIN::EXPLAIN_QEP_TAB
#
DROP TABLE IF EXISTS t1, t2;
create table t1(a char(10) charset latin1, key(a)) engine=innodb;
create table t2(a binary(10), key(a)) engine=innodb;
insert into t1 values('1'),('2'),('3');
insert into t2 values('1'),('2'),('s');
analyze table t1,t2;
Table	Op	Msg_type	Msg_text
mysqltest1.t1	analyze	status	OK
mysqltest1.t2	analyze	status	OK
# Connection cq
# Let thread1 to suspend itself right before creating Quick object.
SET DEBUG_SYNC= 'quick_not_created SIGNAL ready_for_explain WAIT_FOR explained';
select 1 from  t1 inner join t2 using(a);  ;
# Connection ce
SET DEBUG_SYNC= 'now WAIT_FOR ready_for_explain';
SET DEBUG_SYNC= 'after_explain_other SIGNAL explained';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t2	NULL	index	a	a	11	NULL	3	100.00	Using index
1	SIMPLE	t1	NULL	ALL	a	NULL	NULL	NULL	3	100.00	Range checked for each record (index map: 0x1)
connection: cq
1
SET DEBUG_SYNC= 'RESET';
# Connection cq
# Let thread1 to suspend itself right before the mutex section.
SET DEBUG_SYNC= 'quick_created_before_mutex SIGNAL ready_for_explain WAIT_FOR explained';
select 1 from  t1 inner join t2 using(a);;
# Connection ce
SET DEBUG_SYNC= 'now WAIT_FOR ready_for_explain';
SET DEBUG_SYNC= 'after_explain_other SIGNAL explained';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t2	NULL	index	a	a	11	NULL	3	100.00	Using index
1	SIMPLE	t1	NULL	ALL	a	NULL	NULL	NULL	3	100.00	Range checked for each record (index map: 0x1)
connection: cq
1
SET DEBUG_SYNC= 'RESET';
# Connection cq
# Let thread1 to suspend itself right after quick object is droped.
SET DEBUG_SYNC= 'quick_droped_after_mutex SIGNAL ready_for_explain WAIT_FOR explained';
select 1 from  t1 inner join t2 using(a);;
# Connection ce
SET DEBUG_SYNC= 'now WAIT_FOR ready_for_explain';
SET DEBUG_SYNC= 'after_explain_other SIGNAL explained';
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t2	NULL	index	a	a	11	NULL	3	100.00	Using index
1	SIMPLE	t1	NULL	range	a	a	11	NULL	3	100.00	Range checked for each record (index map: 0x1)
connection: cq
1
# Connection default
DROP TABLE t1, t2;
SET DEBUG_SYNC= 'RESET';
# End of test Bug#19822146
USE test;
DROP DATABASE mysqltest1;
# End of test

Man Man