MySQL Forums
Forum List  »  Performance

Re: Adding index kills query
Posted by: Øystein Grøvlen
Date: April 28, 2014 06:06AM

Hi,

It seems I over-looked that the EXPLAIN shows that the optimizer selects the idxComp index instead of the covering index idxCompPurchAmt. This will be much slower than a table scan since it means that both the whole index and the whole table must be read, and the table will not be read in sequential order like with a table scan. I suspect this is a bug in MySQL 5.5 that is may be fixed in later versions. (There are several bugs in MySQL 5.5 wrt choosing index to avoid sorting).

If my suspicion is correct, the following query should give better performance:

SELECT iCompanyID, SUM(fPurchaseAmt)
FROM Trans_smp
FORCE INDEX (idxCompPurchAmt)
GROUP BY iCompanyID;

However, I suggest you also upgrade to a newer version of MySQL.


Hope this helps,

Øystein Grøvlen,
Senior Principal Software Engineer,
MySQL Group, Oracle,
Trondheim, Norway

Options: ReplyQuote


Subject
Views
Written By
Posted
2506
April 23, 2014 06:10PM
1119
April 23, 2014 06:14PM
1162
April 24, 2014 02:44AM
1300
April 24, 2014 09:07AM
1110
April 25, 2014 07:39AM
1253
April 25, 2014 11:54AM
1152
April 25, 2014 02:25PM
Re: Adding index kills query
1245
April 28, 2014 06:06AM
1036
April 24, 2014 09:37AM
1083
April 24, 2014 06:31PM
1370
April 24, 2014 07:10PM
1185
April 24, 2014 07:19PM
1353
April 25, 2014 10:55AM
1043
April 25, 2014 11:02PM
2000
April 27, 2014 07:53PM
1128
April 27, 2014 08:50PM
1114
April 27, 2014 09:00PM


Sorry, you can't reply to this topic. It has been closed.

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.