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
2295
April 23, 2014 06:10PM
1026
April 23, 2014 06:14PM
1065
April 24, 2014 02:44AM
1208
April 24, 2014 09:07AM
1022
April 25, 2014 07:39AM
1146
April 25, 2014 11:54AM
1069
April 25, 2014 02:25PM
Re: Adding index kills query
1122
April 28, 2014 06:06AM
941
April 24, 2014 09:37AM
992
April 24, 2014 06:31PM
1272
April 24, 2014 07:10PM
1095
April 24, 2014 07:19PM
1238
April 25, 2014 10:55AM
949
April 25, 2014 11:02PM
1909
April 27, 2014 07:53PM
1028
April 27, 2014 08:50PM
1014
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.