MDEV-13628: ORed condition in pushed index condition is not removed from the WHERE

So to push index condition for each join tab we have calculate the index condition that can be pushed and then
remove this index condition from the original condition. This is done through the function make_cond_remainder.
The problem is the function make_cond_remainder does not remove index condition when there is an OR operator.

Fixed this by making the function make_cond_remainder to keep in mind of the OR operator.
Also updated results for multiple test files which were incorrectly updated by the commit e0c1b3f242

code which was supposed to remove the condition present in the index
condition was not getting executed when the condition had OR operator, with AND the pushed
index condition was getting removed from where.

This problem affects all versions starting from 5.5 but this is a performance improvement, so fixing it in 10.4
This commit is contained in:
Varun Gupta 2019-05-11 20:44:18 +05:30
commit 6a365e0bf2
21 changed files with 101 additions and 52 deletions

View file

@ -288,7 +288,7 @@ WHERE Code NOT IN (SELECT Country FROM CountryLanguage WHERE Language = 'English
AND (CountryLanguage.Language = 'French' OR CountryLanguage.Language = 'Spanish')
AND Code = Country;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY CountryLanguage range PRIMARY,Language Language 30 NULL 44 Using index condition; Using where; Rowid-ordered scan
1 PRIMARY CountryLanguage range PRIMARY,Language Language 30 NULL 44 Using index condition; Rowid-ordered scan
1 PRIMARY Country eq_ref PRIMARY PRIMARY 3 world.CountryLanguage.Country 1 Using where
3 MATERIALIZED CountryLanguage ref PRIMARY,Language Language 30 const 48 Using index condition
set statement optimizer_switch='rowid_filter=off' for