[MDEV-758] LP:1052523 - Unexpected index condition pushdown behaviour on range queries with InnoDB plugin Created: 2012-09-18 Updated: 2012-12-25 Resolved: 2012-12-25 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 5.5.29 |
| Type: | Bug | Priority: | Minor |
| Reporter: | Ovais Tariq | Assignee: | Elena Stepanova |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | Launchpad | ||
| Attachments: |
|
| Description |
|
MariaDB version >= 5.5.23 does not use index condition pushdown for range query, when it should. I have tested it with both 5.5.23 and 5.5.27. The same query when run against MySQL 5.6.6-m9 and MariaDB 5.3.5 results in index condition pushdown being used. – Test case:
The data to use with the table is attached with this bug report. Explain output is seen on MariaDB 5.5.27:
Explain output as seen on MySQL 5.6.6-m9:
Explain output as seen on MariaDB 5.3.5:
This obviously means that the above query executes slowly on MariaDB 5.5.27.
The query time on MariaDB 5.5.27:
This is because MariaDB 5.5.27 is reading more data (Handler_read_* = 19328), while MySQL 5.6.6-m9 and MariaDB 5.3.5 are reading far fewer data (Handler_read_* = 10) |
| Comments |
| Comment by Ovais Tariq [ 2012-09-18 ] | ||||||||||||||||||||||||||||||||||||||||
|
Re: Unexpected index condition pushdown behaviour on range queries | ||||||||||||||||||||||||||||||||||||||||
| Comment by Ovais Tariq [ 2012-09-18 ] | ||||||||||||||||||||||||||||||||||||||||
|
Table data to use with the table structure in the bug report | ||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2012-09-18 ] | ||||||||||||||||||||||||||||||||||||||||
|
Re: Unexpected index condition pushdown behaviour on range queries I'm getting ICP with your test case (tried 5.5.27 which is the latest 5.5 release): MariaDB [test]> CREATE TABLE `icp_test` ( MariaDB [test]> SOURCE icp_test.dump; Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.05 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.07 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 21539 rows affected (0.93 sec) Query OK, 21405 rows affected (0.89 sec) Query OK, 21405 rows affected (1.27 sec) Query OK, 21000 rows affected (0.91 sec) Query OK, 20977 rows affected (1.40 sec) Query OK, 20975 rows affected (1.22 sec) Query OK, 20976 rows affected (1.21 sec) Query OK, 20976 rows affected (0.94 sec) Query OK, 20974 rows affected (1.23 sec) Query OK, 20975 rows affected (1.89 sec) Query OK, 20975 rows affected (1.68 sec) Query OK, 20976 rows affected (1.22 sec) Query OK, 20977 rows affected (1.39 sec) Query OK, 20976 rows affected (1.54 sec) Query OK, 20977 rows affected (1.74 sec) Query OK, 20976 rows affected (0.99 sec) Query OK, 20977 rows affected (1.34 sec) Query OK, 20978 rows affected (1.99 sec) Query OK, 20975 rows affected (2.26 sec) Query OK, 20976 rows affected (1.35 sec) Query OK, 20975 rows affected (2.18 sec) Query OK, 20979 rows affected (1.67 sec) Query OK, 20976 rows affected (1.80 sec) Query OK, 20977 rows affected (1.27 sec) Query OK, 20976 rows affected (1.94 sec) Query OK, 20976 rows affected (2.09 sec) Query OK, 20976 rows affected (1.69 sec) Query OK, 20976 rows affected (1.63 sec) Query OK, 20975 rows affected (3.62 sec) Query OK, 20976 rows affected (1.31 sec) Query OK, 20974 rows affected (1.06 sec) Query OK, 20976 rows affected (2.50 sec) Query OK, 20975 rows affected (1.12 sec) Query OK, 20975 rows affected (1.06 sec) Query OK, 20976 rows affected (2.84 sec) Query OK, 20607 rows affected (1.52 sec) Query OK, 20565 rows affected (2.88 sec) Query OK, 20563 rows affected (2.95 sec) Query OK, 20563 rows affected (1.42 sec) Query OK, 20565 rows affected (3.37 sec) Query OK, 20563 rows affected (1.84 sec) Query OK, 20564 rows affected (4.93 sec) Query OK, 20562 rows affected (1.66 sec) Query OK, 20566 rows affected (1.69 sec) Query OK, 20564 rows affected (4.25 sec) Query OK, 20565 rows affected (1.89 sec) Query OK, 20564 rows affected (4.36 sec) Query OK, 20564 rows affected (2.15 sec) Query OK, 20563 rows affected (1.32 sec) Query OK, 20563 rows affected (5.50 sec) Query OK, 4472 rows affected (0.87 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.00 sec) MariaDB [test]> EXPLAIN SELECT * FROM icp_test WHERE k BETWEEN 4000 AND 5000 AND i < 1000 ORDER BY k ASC LIMIT 10\G
MariaDB [test]> select @@version;
----------------
---------------- | ||||||||||||||||||||||||||||||||||||||||
| Comment by Ovais Tariq [ 2012-09-19 ] | ||||||||||||||||||||||||||||||||||||||||
|
Re: Unexpected index condition pushdown behaviour on range queries I am able to reproduce this with 5.5.23 and 5.5.27. Following is how the optimizer_switch values look like: MariaDB [test]> select @@optimizer_switch\G
You can see index_condition_pushdown=on Every time I run this query, the EXPLAIN shows its not using ICP. However, the same query run any number of times on MySQL 5.6.6-m9 and 5.3.5 uses ICP. So for me its unpredictable when the optimizer would choose to use ICP. | ||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2012-09-19 ] | ||||||||||||||||||||||||||||||||||||||||
|
Re: Unexpected index condition pushdown behaviour on range queries Please attach your complete cnf file (with all includes, if it has any). I'll check if it makes any difference. | ||||||||||||||||||||||||||||||||||||||||
| Comment by Ovais Tariq [ 2012-09-19 ] | ||||||||||||||||||||||||||||||||||||||||
|
Re: Unexpected index condition pushdown behaviour on range queries | ||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2012-09-19 ] | ||||||||||||||||||||||||||||||||||||||||
|
Re: Unexpected index condition pushdown behaviour on range queries | ||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2012-09-19 ] | ||||||||||||||||||||||||||||||||||||||||
|
Re: Unexpected index condition pushdown behaviour on range queries
--source include/have_innodb.inc CREATE TABLE t1 (i INT NOT NULL, k INT NOT NULL, v CHAR(32), KEY k(k,i)) ENGINE=InnoDB; EXPLAIN SELECT * FROM t1 WHERE k BETWEEN 4000 AND 5000 AND i < 1000 ORDER BY k ASC LIMIT 10; DROP TABLE t1;
-----
-----
-----
-----
-----
----- | ||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2012-09-19 ] | ||||||||||||||||||||||||||||||||||||||||
|
Re: Unexpected index condition pushdown behaviour on range queries with InnoDB plugin | ||||||||||||||||||||||||||||||||||||||||
| Comment by Ovais Tariq [ 2012-09-20 ] | ||||||||||||||||||||||||||||||||||||||||
|
Re: Unexpected index condition pushdown behaviour on range queries with InnoDB plugin So to be able to use the new optimisations in MariaDB 5.5, I need to build with XtraDB? But this is not mentioned in the docs. Also the docs mention that MariaDB 5.5 by default uses XtraDB, so I do not expect mtr to be running with InnoDB by default! | ||||||||||||||||||||||||||||||||||||||||
| Comment by Ovais Tariq [ 2012-09-20 ] | ||||||||||||||||||||||||||||||||||||||||
|
Re: Unexpected index condition pushdown behaviour on range queries with InnoDB plugin As for my comment in bug #1000051, I can see that why ICP is not being used with MariaDB 5.5.23, because mtr would by default disable builtin InnoDB (which is actually XtraDB) and use the InnoDB plugin instead (unexpected behaviour). | ||||||||||||||||||||||||||||||||||||||||
| Comment by Rasmus Johansson (Inactive) [ 2012-09-20 ] | ||||||||||||||||||||||||||||||||||||||||
|
Launchpad bug id: 1052523 | ||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2012-09-20 ] | ||||||||||||||||||||||||||||||||||||||||
|
Re: Unexpected index condition pushdown behaviour on range queries with InnoDB plugin >> So to be able to use the new optimisations in MariaDB 5.5, I need to build with XtraDB? For engine-specific optimizations, like ICP, yes. Both 5.5 and 5.3 are built and run with XtraDB by default, just as you mentioned, so it doesn't seem to be a very strict requirement, but you are right, it should be mentioned in the docs, we'll fix that. >> Also the docs mention that MariaDB 5.5 by default uses XtraDB, so I do not expect mtr to be running with InnoDB by default! MTR configuration is not even remotely close to default MariaDB (or MySQL, for that matter), and it has never been guaranteed, so you shouldn't rely on that. Apart from the engine, it has dozens of non-default parameters. >> As for my comment in bug #1000051, I can see that why ICP is not being used with MariaDB 5.5.23, because mtr would by Please note that the full test case in bug #1000051 uses MyISAM, not InnoDB, as a table engine. If you create your own tables with a different engine and then attempt to use the test data and query to trigger the same execution plan as provided in the test case, it might well not work. The test case contains explicit ENGINE clauses exactly because the behavior can be engine-specific. |