Bug #65792 an unecessary Using temporary in distinct query

Submitted: 3 Jul 2012 2:19 Modified: 3 Jul 2012 4:17
Reporter: xiaobin lin (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S5 (Performance)
Version:5.1,5.5 OS:Any
Assigned to: CPU Architecture:Any
Tags: distinct, temporary

[3 Jul 2012 2:19] xiaobin lin
Description:
Look into this case http://ww1.sinaimg.cn/large/733db945gw1duinwgwjwij.jpg

When the optimizer decide whether the query can use the index (a,b), it use the function test_if_order_by_key. So the (b, a) in query can not use this index. 

It is distinct here, but not "order by b, a", perhaps it is better to use the way that ignore the column order in index ? 

This cause about 20% performance decrease.

How to repeat:
as above

Suggested fix:
Use a check function that ignore the order of column in index. In fact, when columns satisfy the left-most of an index,  the index can be used.
[3 Jul 2012 4:17] Valeriy Kravchuk
Sounds like a reasonable feature request.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.052 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.