We had discussion today which involved benchmarks of Join speed for MyISAM and Innodb storage engines for CPU bound workload, this is when data size is small enough to fit in memory and so buffer pool.
I tested very simple table, having with about 20.000 rows in it on 32bit Linux. The columns “id” “i” and “c” were populated with same integers so we can allow the same job to be done using different kinds of columns – primary key, integer indexed column and indexed char column. The query is also trivial – the point was to make sure it is not index covered query so it reads the rows and it does not return many rows. I varied the join clause to be id, i and C columns appropriately.
CREATE TABLE `t1` (
`id` int(10) unsigned NOT NULL default '0',
`i` int(10) unsigned NOT NULL default '0',
`c` char(15) default NULL,
`pad` char(8) default NULL,
PRIMARY KEY (`id`),
KEY `i` (`i`),
KEY `c` (`c`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
select count(t1.pad),count(t2.pad) from t1,t1 t2 where t1.id=t2.id;
The result I’ve got are as follows
As you see in such circumstances Innodb is actually faster than MyISAM in 2 cases out of 3. I guess the reasons are the following:
Note: This applies to CPU bound workload with all content fitting in memory. In other cases situation is very different and MyISAM compression for char keys could frequently positevely impact performance.
Percona’s widely read Percona Data Performance blog highlights our expertise in enterprise-class software, support, consulting and managed services solutions for both MySQL® and MongoDB® across traditional and cloud-based platforms. The decades of experience represented by our consultants is found daily in numerous and relevant blog posts.
Besides specific database help, the blog also provides notices on upcoming events and webinars.
Want to get weekly updates listing the latest blog posts? Subscribe to our blog now! Submit your email address below.