Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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: T135027152
- Loading branch information