DBT3 S30: Q18 uses ICP for InnoDB but not for MyISAM
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MariaDB |
Invalid
|
Undecided
|
Igor Babaev |
Bug Description
When DBT3 Q18 is run against an InnoDB database, it uses ICP, if run
with the same settings against the same MyISAM database, ICP is not used.
EXPLAINs:
InnoDB:
set @@optimizer_
+----+-
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-
| 1 | PRIMARY | customer | ALL | PRIMARY | NULL | NULL | NULL | 4476636 | Using temporary; Using filesort |
| 1 | PRIMARY | orders | ref | PRIMARY,i_o_custkey | i_o_custkey | 5 | dbt3.customer.
| 1 | PRIMARY | lineitem | ref | PRIMARY,
| 2 | SUBQUERY | lineitem | index | NULL | PRIMARY | 8 | NULL | 179175334 | |
+----+-
(5 min 0.98 sec)
MYISAM:
set @@optimizer_
+----+-
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-
| 1 | PRIMARY | customer | ALL | PRIMARY | NULL | NULL | NULL | 4500000 | Using temporary; Using filesort |
| 1 | PRIMARY | orders | ref | PRIMARY,i_o_custkey | i_o_custkey | 5 | dbt3.customer.
| 1 | PRIMARY | lineitem | ref | PRIMARY,
| 2 | SUBQUERY | lineitem | index | NULL | i_l_orderkey_
+----+-
Changed in maria: | |
milestone: | none → 5.3 |
assignee: | nobody → Sergey Petrunia (sergefp) |
The query is
select sql_calc_found_rows
c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice, sum(l_quantity)
from customer, orders, lineitem
where
and c_custkey = o_custkey and o_orderkey = l_orderkey
group by c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice
order by o_totalprice desc, o_orderdate
limit 10;
When we access the table orders in both cases we use the index i_o_custkey.
In InnoDB ICP can be applied for extended keys. So acctually in innoDB when
testing applicability of ICP we consider the extended key (o_custkey, o_orderkey),
and the condition
o_orderkey in (select l_orderkey from lineitem group by l_orderkey having sum(l_quantity) > 300)
can be pushed into this index.