Server : Debian baremetal server, this is the only product installed. Data is stored on a 4x1Tb SSD with material RAID 5
Client : Tested with mycli / mysql command / dbeaver on 2 different workstation on debian
Description
After migrating from mariadb 10.1.38-0+deb9u1 (provided by debian) to 10.4.6+maria~stretch, some request including IN (or multiple OR) and filtering on multiple columns indexed separately :
Thanks a lot for the report!
As a workaround, you can try setting optimizer_switch='rowid_filter=off'
--source include/have_sequence.inc
--source include/have_innodb.inc
createtable t1 ( a int, b int, key (b), key (a)) engine=innodb;
insertinto t1 select seq+10000, 2 from seq_1_to_1000;
insertinto t1 select 10100, 2 from seq_1_to_50;
selectcount(*) from t1 where a in(10100,1) and b = 2;
set optimizer_switch='rowid_filter=off';
selectcount(*) from t1 where a in(10100,1) and b = 2;
droptable t1;
MariaDB [test]> select count(*) from t1 where a in(10100,1) and b = 2;
+----------+
| count(*) |
+----------+
| 0 |
+----------+
1 row in set (0.001 sec)
MariaDB [test]> set optimizer_switch='rowid_filter=off';
Query OK, 0 rows affected (0.000 sec)
MariaDB [test]> select count(*) from t1 where a in(10100,1) and b = 2;
+----------+
| count(*) |
+----------+
| 51 |
+----------+
1 row in set (0.001 sec)
Alice Sherepa
added a comment - Thanks a lot for the report!
As a workaround, you can try setting optimizer_switch='rowid_filter=off'
--source include/have_sequence.inc
--source include/have_innodb.inc
create table t1 ( a int , b int , key (b), key (a)) engine=innodb;
insert into t1 select seq+10000, 2 from seq_1_to_1000;
insert into t1 select 10100, 2 from seq_1_to_50;
select count (*) from t1 where a in (10100,1) and b = 2;
set optimizer_switch= 'rowid_filter=off' ;
select count (*) from t1 where a in (10100,1) and b = 2;
drop table t1;
MariaDB [test]> select count(*) from t1 where a in(10100,1) and b = 2;
+----------+
| count(*) |
+----------+
| 0 |
+----------+
1 row in set (0.001 sec)
MariaDB [test]> set optimizer_switch='rowid_filter=off';
Query OK, 0 rows affected (0.000 sec)
MariaDB [test]> select count(*) from t1 where a in(10100,1) and b = 2;
+----------+
| count(*) |
+----------+
| 51 |
+----------+
1 row in set (0.001 sec)
I suggested a little shorter fix. In the case when the rowid filter does not match, it will do some extra work and convert all available fields of the index record, not only the rowid column.
Marko Mäkelä
added a comment - I suggested a little shorter fix . In the case when the rowid filter does not match, it will do some extra work and convert all available fields of the index record, not only the rowid column.
Thanks a lot for the report!
As a workaround, you can try setting optimizer_switch='rowid_filter=off'
--source include/have_sequence.inc
--source include/have_innodb.inc
MariaDB [test]> select count(*) from t1 where a in(10100,1) and b = 2;
+----------+
| count(*) |
+----------+
| 0 |
+----------+
1 row in set (0.001 sec)
MariaDB [test]> set optimizer_switch='rowid_filter=off';
Query OK, 0 rows affected (0.000 sec)
MariaDB [test]> select count(*) from t1 where a in(10100,1) and b = 2;
+----------+
| count(*) |
+----------+
| 51 |
+----------+
1 row in set (0.001 sec)