Commit 04ddd79
Fix inefficient range tree construction from IN list
Summary:
Fixes https://bugs.mysql.com/108963
When constructing the range tree, we end up re-merging the current tree for every element of the IN list, and this causes optimization to be very slow. Fix this by switching the order of arguments, so that we always merge the new item into the existing tree instead.
I've also considered fixing `key_or` to automatically swap the order of arguments, but there is already existing swapping logic that considers which tree needs copied vs can be edited in place, and it seems unclear how to integrate with that effectively (since the two goals could be conflicting).
Test Plan:
tested manually using the query affecting user
before:
```
+----+-------------+------------------------------+------------+------+---------------+------+---------+------+------+----------+-------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+------------------------------+------------+------+---------------+------+---------+------+------+----------+-------------+
| 1 | SIMPLE | nee_violation_obj_chg_events | NULL | ALL | unique_event | NULL | NULL | NULL | 1 | 100.00 | Using where |
+----+-------------+------------------------------+------------+------+---------------+------+---------+------+------+----------+-------------+
1 row in set, 40970 warnings (6 min 24.58 sec)
```
after
```
+----+-------------+------------------------------+------------+------+---------------+------+---------+------+------+----------+-------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+------------------------------+------------+------+---------------+------+---------+------+------+----------+-------------+
| 1 | SIMPLE | nee_violation_obj_chg_events | NULL | ALL | unique_event | NULL | NULL | NULL | 1 | 100.00 | Using where |
+----+-------------+------------------------------+------------+------+---------------+------+---------+------+------+----------+-------------+
1 row in set, 40970 warnings (0.34 sec)
```
Reviewers: herman, yoshinori, #mysql_eng
Reviewed By: herman
Subscribers: pgl
Differential Revision: https://phabricator.intern.facebook.com/D40948362
Tasks: T1350271521 parent f51a654 commit 04ddd79
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
421 | 421 | | |
422 | 422 | | |
423 | 423 | | |
424 | | - | |
| 424 | + | |
425 | 425 | | |
426 | 426 | | |
427 | 427 | | |
| |||
0 commit comments