Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MariaDB [test]> explain select a, (select sum(X.a+B.b) from ten X, t1big B where B.a=A.a or B.b=A.a) from ten A;
- +----+--------------------+-------+------+---------------+------+---------+------+------+-------------------------------------------------+
- | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
- +----+--------------------+-------+------+---------------+------+---------+------+------+-------------------------------------------------+
- | 1 | PRIMARY | A | ALL | NULL | NULL | NULL | NULL | 10 | |
- | 2 | DEPENDENT SUBQUERY | X | ALL | NULL | NULL | NULL | NULL | 10 | |
- | 2 | DEPENDENT SUBQUERY | B | ALL | a,b | NULL | NULL | NULL | 1000 | Using where; Using join buffer (flat, BNL join) |
- +----+--------------------+-------+------+---------------+------+---------+------+------+-------------------------------------------------+
- MariaDB [test]> create table all_numbers (a int primary key);
- MariaDB [test]> insert into all_numbers select * from test.one_k;
- MariaDB [test]> explain select a, (select sum(X.a+B.b) from ten X, t1big B, all_numbers where B.a=all_numbers.a or B.b=all_numbers.a and all_numbers.a=A.a) from ten A;
- +----+--------------------+-------------+-------+---------------+---------+---------+------+------+-------------------------------------------------+
- | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
- +----+--------------------+-------------+-------+---------------+---------+---------+------+------+-------------------------------------------------+
- | 1 | PRIMARY | A | ALL | NULL | NULL | NULL | NULL | 10 | |
- | 2 | DEPENDENT SUBQUERY | X | ALL | NULL | NULL | NULL | NULL | 10 | |
- | 2 | DEPENDENT SUBQUERY | all_numbers | index | PRIMARY | PRIMARY | 4 | NULL | 1000 | Using index; Using join buffer (flat, BNL join) |
- | 2 | DEPENDENT SUBQUERY | B | ALL | a,b | NULL | NULL | NULL | 1000 | Range checked for each record (index map: 0x3) |
- +----+--------------------+-------------+-------+---------------+---------+---------+------+------+-------------------------------------------------+
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement