Optimizer doesn't choose best execution plan when composite key is used.

Description

MariaDB optimizer doesn't choose best execution plan when they use composite key.

There's composite key with two columns (pk1 + fd5).
The the query which have (pk1=? and fd5>?) where condition and ORDER BY fd5 clause
generate plan using only "pk1" column.
It also happen in MariaDB 5.5.24.

See below test case.
I can't upload sample data of table, becaus it's too big and it's also real service data. I think you can generate test data with index cardinality and table status.

Test case ------------------------------------------------------------------------------

Environment

Linux matt001 2.6.18-308.el5 #1 SMP Tue Feb 21 20:06:06 EST 2012 x86_64 x86_64 x86_64 GNU/Linux

Assignee

Sergei Petrunia

Reporter

mattl

Components

Fix versions

Affects versions

Priority

Major
Configure