Bug #102728 why update not support index condition pushdown
Submitted: 25 Feb 2021 3:25 Modified: 23 Mar 2021 13:48
Reporter: casa zhang (OCA) Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S4 (Feature request)
Version:5.7 OS:Any
Assigned to: CPU Architecture:Any

[25 Feb 2021 3:25] casa zhang
Description:
CREATE TABLE `t2` (
  `a` int(11) DEFAULT NULL,
  `b` int(11) DEFAULT NULL,
  `c` char(10) DEFAULT NULL,
  `d` varchar(256) DEFAULT NULL,
  `e` text,
  KEY `ii1` (`a`,`b`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

sql1: update t2 set b = 3 where a = 1;
sql2: select b from t2 where a = 1;

sql2 will use index condition pushdown, but sql1 doesn't, but why, is that data format between engine and server transformation?

How to repeat:
mysql> explain select b from t2 where a = 1;
+----+-------------+-------+------------+------+---------------+------+---------+-------+------+----------+-------------+
| id | select_type | table | partitions | type | possible_keys | key  | key_len | ref   | rows | filtered | Extra       |
+----+-------------+-------+------------+------+---------------+------+---------+-------+------+----------+-------------+
|  1 | SIMPLE      | t2    | NULL       | ref  | ii1           | ii1  | 5       | const |    1 |   100.00 | Using index |
+----+-------------+-------+------------+------+---------------+------+---------+-------+------+----------+-------------+
1 row in set, 1 warning (0.00 sec)

mysql> explain update t2 set b = 3 where a = 1;
+----+-------------+-------+------------+-------+---------------+------+---------+-------+------+----------+------------------------------+
| id | select_type | table | partitions | type  | possible_keys | key  | key_len | ref   | rows | filtered | Extra                        |
+----+-------------+-------+------------+-------+---------------+------+---------+-------+------+----------+------------------------------+
|  1 | UPDATE      | t2    | NULL       | range | ii1           | ii1  | 5       | const |    1 |   100.00 | Using where; Using temporary |
+----+-------------+-------+------------+-------+---------------+------+---------+-------+------+----------+------------------------------+
1 row in set (0.00 sec)
[23 Mar 2021 13:48] MySQL Verification Team
Hi Mr. zhang,

Thank you for your bug report.

However, this is not a bug.

Simply, none of these two statements uses ICP, otherwise the "Extra" column in the EXPLAIN would have shown it.

Using 8.0 and several EXPLAIN variants might prove more informations.

Not a bug.