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
2286
April 23, 2014 06:10PM
1019
April 23, 2014 06:14PM
1059
April 24, 2014 02:44AM
1205
April 24, 2014 09:07AM
1009
April 25, 2014 07:39AM
1140
April 25, 2014 11:54AM
1063
April 25, 2014 02:25PM
Re: Adding index kills query
1105
April 28, 2014 06:06AM
923
April 24, 2014 09:37AM
981
April 24, 2014 06:31PM
1266
April 24, 2014 07:10PM
1085
April 24, 2014 07:19PM
1224
April 25, 2014 10:55AM
942
April 25, 2014 11:02PM
1898
April 27, 2014 07:53PM
1023
April 27, 2014 08:50PM
1008
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.