In this blog post, I’ll look at
whether optimizing indexing is always the key to improving
MySQL query performance (spoiler, it isn’t).
As we look at MySQL query performance, our first concern is often
whether a query is using the right indexes to retrieve the data.
This is based on the assumption that finding the data is the most
expensive operation – and the one you should focus on for MySQL
query optimization. However, this is not always the case.
Let’s look at this query for illustration:
mysql> show create table tbl G
*************************** 1. row ***************************
Table: tbl
Create Table: CREATE TABLE `tbl` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`k` int(11) NOT NULL DEFAULT '0',
`g` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
KEY `k_1` (`k`)
) ENGINE=InnoDB …
[Read more]