1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
CREATE TABLE t1 (t1i int);
CREATE TABLE t2 (t2i int);
CREATE TABLE t3 (t3i int);
CREATE TABLE t4 (t4i int);
INSERT INTO t1 VALUES (1);
INSERT INTO t2 VALUES (1),(2);
INSERT INTO t3 VALUES (1),(2);
INSERT INTO t4 VALUES (1),(2);
EXPLAIN
SELECT t1i
FROM t1 JOIN t4 ON t1i=t4i
WHERE (t1i) IN (
SELECT t2i
FROM t2
WHERE (t2i) IN (
SELECT t3i
FROM t3
GROUP BY t3i
)
);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 1 Using where
1 PRIMARY t4 ALL NULL NULL NULL NULL 2 Using where; Using join buffer
2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where
3 SUBQUERY t3 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
DROP TABLE t1,t2,t3,t4;
|