MariaDB [mytest]> explain (SELECT r1.id1,r2.id2
|
-> FROM r1 JOIN r2 ON r1.id1 = r2.id2 limit 10)
|
-> union select 1,2 order by 1;
|
+------+--------------+------------+------+---------------+------+---------+------+------+-------------------------------------------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
+------+--------------+------------+------+---------------+------+---------+------+------+-------------------------------------------------+
|
| 1 | PRIMARY | r1 | ALL | NULL | NULL | NULL | NULL | 2000 | |
|
| 1 | PRIMARY | r2 | ALL | NULL | NULL | NULL | NULL | 2000 | Using where; Using join buffer (flat, BNL join) |
|
| 2 | UNION | NULL | NULL | NULL | NULL | NULL | NULL | NULL | No tables used |
|
| NULL | UNION RESULT | <union1,2> | ALL | NULL | NULL | NULL | NULL | NULL | Using filesort |
|
+------+--------------+------------+------+---------------+------+---------+------+------+-------------------------------------------------+
|
4 rows in set (0.002 sec)
|
|
MariaDB [mytest]> explain (SELECT r1.id1,r2.id2
|
-> FROM r1 JOIN r2 ON r1.id1 = r2.id2 limit 10)
|
-> union select 1,2 limit 5;
|
+------+--------------+------------+------+---------------+------+---------+------+------+-------------------------------------------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
+------+--------------+------------+------+---------------+------+---------+------+------+-------------------------------------------------+
|
| 1 | PRIMARY | r1 | ALL | NULL | NULL | NULL | NULL | 2000 | |
|
| 1 | PRIMARY | r2 | ALL | NULL | NULL | NULL | NULL | 2000 | Using where; Using join buffer (flat, BNL join) |
|
| 2 | UNION | NULL | NULL | NULL | NULL | NULL | NULL | NULL | No tables used |
|
| NULL | UNION RESULT | <union1,2> | ALL | NULL | NULL | NULL | NULL | NULL | |
|
+------+--------------+------------+------+---------------+------+---------+------+------+-------------------------------------------------+
|
4 rows in set (0.002 sec)
|
|
|
MariaDB [mytest]> explain select count(id1) from r1 union all select 1 order by 1;
|
+------+--------------+------------+------+---------------+------+---------+------+------+----------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
+------+--------------+------------+------+---------------+------+---------+------+------+----------------+
|
| 1 | PRIMARY | r1 | ALL | NULL | NULL | NULL | NULL | 2000 | |
|
| 2 | UNION | NULL | NULL | NULL | NULL | NULL | NULL | NULL | No tables used |
|
| NULL | UNION RESULT | <union1,2> | ALL | NULL | NULL | NULL | NULL | NULL | Using filesort |
|
+------+--------------+------------+------+---------------+------+---------+------+------+----------------+
|
3 rows in set (0.001 sec)
|
|
MariaDB [mytest]> explain select count(id1) from r1 union all select 1 limit 5;
|
+------+-------------+-------+------+---------------+------+---------+------+------+----------------+
|
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
|
+------+-------------+-------+------+---------------+------+---------+------+------+----------------+
|
| 1 | PRIMARY | r1 | ALL | NULL | NULL | NULL | NULL | 2000 | |
|
| 2 | UNION | NULL | NULL | NULL | NULL | NULL | NULL | NULL | No tables used |
|
+------+-------------+-------+------+---------------+------+---------+------+------+----------------+
|
2 rows in set (0.001 sec)
|