Comment 1 for bug 934348

Revision history for this message
Igor Babaev (igorb-seattle) wrote :

The problem is seen already in the execution plan:

MariaDB [test]> EXPLAIN SELECT a FROM t1 t WHERE t.a IN ( SELECT b FROM t1, t2 WHERE b = a ) GROUP BY t.a HAVING t.a != 'z';
+----+--------------+-------------+------+---------------+------+---------+-----------+------+----------+---------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+--------------+-------------+------+---------------+------+---------+-----------+------+----------+---------------------------------+
| 1 | PRIMARY | <subquery2> | ALL | distinct_key | NULL | NULL | NULL | 2 | 100.00 | Using temporary; Using filesort |
| 1 | PRIMARY | t | ref | a | a | 4 | test.t1.a | 2 | 100.00 | Using where; Using index |
| 2 | MATERIALIZED | t2 | ALL | NULL | NULL | NULL | NULL | 2 | 100.00 | Using where |
| 2 | MATERIALIZED | t1 | ref | a | a | 4 | test.t2.b | 2 | 100.00 | Using where; Using index |
+----+--------------+-------------+------+---------------+------+---------+-----------+------+----------+-------------------

The key to access t is built oveer column a of the materialized table. Yet there is no such column there.