Bug #83248 | Partition pruning is not working with LEFT JOIN | ||
---|---|---|---|
Submitted: | 3 Oct 2016 15:57 | Modified: | 3 Oct 2016 17:12 |
Reporter: | Valeriy Kravchuk | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
Version: | 8.0.0, 5.7.15 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | Optimizer, partition, pruning |
[3 Oct 2016 15:57]
Valeriy Kravchuk
[3 Oct 2016 16:56]
MySQL Verification Team
See https://bugs.mysql.com/bug.php?id=26630.
[3 Oct 2016 17:12]
MySQL Verification Team
Thank you for the bug report. mysql 5.7 > explain partitions select a.a_id , a.b_id, c.c_id from a JOIN b on b.b_id = a.b_id and a.d = b.d LEFT JOIN c on a.c_id = c.c_id and a.d = c.d where a.d BETWEEN '2016-07-11' AND '2016-07-11' LIMIT 10; +----+-------------+-------+---------------------------------------+--------+---------------+---------+---------+------------------+------+----------+--------------------------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+-------+---------------------------------------+--------+---------------+---------+---------+------------------+------+----------+--------------------------+ | 1 | SIMPLE | a | p160711 | ALL | b_id | NULL | NULL | NULL | 1 | 100.00 | Using where | | 1 | SIMPLE | b | p160711 | eq_ref | PRIMARY | PRIMARY | 11 | p1.a.b_id,const | 1 | 100.00 | Using where; Using index | | 1 | SIMPLE | c | p160709,p160710,p160711,p160712,p9999 | eq_ref | PRIMARY | PRIMARY | 11 | p1.a.c_id,p1.a.d | 1 | 100.00 | Using index | +----+-------------+-------+---------------------------------------+--------+---------------+---------+---------+------------------+------+----------+--------------------------+ 3 rows in set, 2 warnings (0.17 sec) mysql 5.7 > mysql 5.7 > explain partitions select a.a_id , a.b_id, c.c_id from a JOIN b on b.b_id = a.b_id and a.d = b.d INNER JOIN c on a.c_id = c.c_id and a.d = c.d where a.d BETWEEN '2016-07-11' AND '2016-07-11' LIMIT 10; +----+-------------+-------+------------+--------+---------------+---------+---------+-----------------+------+----------+--------------------------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+-------+------------+--------+---------------+---------+---------+-----------------+------+----------+--------------------------+ | 1 | SIMPLE | a | p160711 | ALL | b_id,c_id | NULL | NULL | NULL | 1 | 100.00 | Using where | | 1 | SIMPLE | b | p160711 | eq_ref | PRIMARY | PRIMARY | 11 | p1.a.b_id,const | 1 | 100.00 | Using where; Using index | | 1 | SIMPLE | c | p160711 | eq_ref | PRIMARY | PRIMARY | 11 | p1.a.c_id,const | 1 | 100.00 | Using where; Using index | +----+-------------+-------+------------+--------+---------------+---------+---------+-----------------+------+----------+--------------------------+ 3 rows in set, 2 warnings (0.00 sec) mysql 5.7 > explain select a.a_id , a.b_id, c.c_id from a JOIN b on b.b_id = a.b_id and a.d = b.d LEFT JOIN c on a.c_id = c.c_id and a.d = c.d and a.d BETWEEN '2016-07-11' AND '2016-07-11' where a.d BETWEEN '2016-07-11' AND '2016-07-11' LIMIT 10; +----+-------------+-------+------------+--------+---------------+---------+---------+-----------------+------+----------+--------------------------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+-------+------------+--------+---------------+---------+---------+-----------------+------+----------+--------------------------+ | 1 | SIMPLE | a | p160711 | ALL | b_id | NULL | NULL | NULL | 1 | 100.00 | Using where | | 1 | SIMPLE | b | p160711 | eq_ref | PRIMARY | PRIMARY | 11 | p1.a.b_id,const | 1 | 100.00 | Using where; Using index | | 1 | SIMPLE | c | p160711 | eq_ref | PRIMARY | PRIMARY | 11 | p1.a.c_id,const | 1 | 100.00 | Using where; Using index | +----+-------------+-------+------------+--------+---------------+---------+---------+-----------------+------+----------+--------------------------+ 3 rows in set, 1 warning (0.00 sec) mysql 5.7 > SHOW VARIABLES LIKE "%VERSION%"; +-------------------------+---------------------------------------+ | Variable_name | Value | +-------------------------+---------------------------------------+ | innodb_version | 5.7.17 | | protocol_version | 10 | | slave_type_conversions | | | tls_version | TLSv1,TLSv1.1 | | version | 5.7.17 | | version_comment | Source distribution PULL: 2016-SEP-27 | | version_compile_machine | x86_64 | | version_compile_os | Win64 | +-------------------------+---------------------------------------+ 8 rows in set (0.08 sec)
[7 Sep 2017 15:45]
Arnaud Adant
Any comment from the optimizer team ? This looks like a serious bug when using partitioning.
[22 Feb 2023 1:40]
Arnaud Adant
Any progress ?