Details
-
Bug
-
Status: Closed (View Workflow)
-
Blocker
-
Resolution: Fixed
-
10.5.9, 10.5.13
-
Linux
Description
table with primery key binary(16)
`SELECT from table WHERE key IN (binary form ids, ....)` is extremly slow
while
`SELECT from table WHERE key IN ((0x11e6a2ad166fc342abde002590a2360a),
(0x11e6a2ad16750370aeaf002590a2360a),
(0x11e6a2ad167a186a9e19002590a2360a),....)`
is perfectly fast.
IDs in binary form I mean this: https://tinyurl.com/ycfyftby
Attachments
Issue Links
- causes
-
MDEV-29242 Assertion `computed_weight == weight' failed SEL_ARG::verify_weight
-
- Closed
-
- is caused by
-
MDEV-9750 Quick memory exhaustion with 'extended_keys=on' on queries having multiple 'IN'/'NOT IN' using InnoDB
-
- Closed
-
- relates to
-
MDEV-27530 InnoDB - Performance issues after upgrade 10.4.22 to 10.5.13
-
- Closed
-
-
MDEV-28518 After update to 10.5 a lot of time is spent in "Sending data"
-
- Closed
-
-
MDEV-28638 ANALYZE FORMAT=JSON should print time spent in the optimizer
-
- Closed
-
Indeed, the call to update_weight_locally() is the problem.
update_weight_locally() traverses the whole SEL_ARG tree ("locally" means it doesn't walk across next_key_part edges).
Lets consider a call
key_or(tree1, tree2)
where tree1 has a lot of SEL_ARG nodes,
and tree2 is a tree that has just one SEL_ARG() node.
The code in key_or() will use RB-Tree descend to find the location in tree1 where tree2 should be put in (grep for key1->find_range(key2) call). This takes O(LOG(N)). Adding O(N) in update_weight_locally() will indeed cause a big slowdown.