[MDEV-24413] Combine adjacent "column IN (...)" conditions together Created: 2020-12-15  Updated: 2020-12-15

Status: Open
Project: MariaDB Server
Component/s: Optimizer
Affects Version/s: 10.3, 10.4, 10.5
Fix Version/s: 10.6

Type: Bug Priority: Major
Reporter: Sergei Petrunia Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Filing this as a followup to the discussion about MDEV-21958.

The idea is to do the following: catch this pattern in the WHERE/ON condition:

colX IN (constA_1, ..., constA_N1) OR
colX IN (constB_1, ..., const_BN2) OR 
...

and rewrite it as

colX IN (constA_1, ..., constA_N1, constB_1, ..., const_BN2) OR ...

That is, join the IN-predicates together into one.

Do the same for sibling NOT IN (... ) predicates which are part of an AND.

The idea is that single IN-list is processed efficiently by the range optimizer, while multiple IN-lists are not. This will work around the problem.

The change needs to be performed (TODO: don't recall: late in Prepare stage, or the first in the execution stage). Execution stage is better because this is a rewrite. Prepare is better because we can make destructive modifications to the IN-lists.


Generated at Thu Feb 08 09:29:48 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.