表:
复制代码 代码如下:
create table if not exists `foo` (
`a` int(10) unsigned not null auto_increment,
`b` int(10) unsigned not null,
`c` varchar(100) not null,
primary key (`a`),
key `bar` (`b`,`a`)
) engine=innodb;
create table if not exists `foo2` (
`a` int(10) unsigned not null auto_increment,
`b` int(10) unsigned not null,
`c` varchar(100) not null,
primary key (`a`),
key `bar` (`b`,`a`)
) engine=myisam;
我往两个表中插入了30w的数据(插入的时候性能差别innodb比myisam慢)
复制代码 代码如下:
set profiling = 1;
mysql>show profiles;
mysql>show profile for query 1;
这个数据中就可以看到myisam的sending data比innodb的sending data费时太多了。查看mysql文档http://dev.mysql.com/doc/refman/5.0/en/general-thread-states.html
sending data
the thread is reading and processing rows for a select statement, and sending data to the client. because operations occurring during this this state tend to perform large amounts of disk access (reads), it is often the longest-running state over the lifetime of a given query.
sending data是去磁盘中读取select的结果,然后将结果返回给客户端。这个过程会有大量的io操作。你可以使用show profile cpu for query xx;来进行查看,发现myisam的cpu_system比innnodb大很多。至此可以得出结论是myisam进行表查询(区别仅仅使用索引就可以完成的查询)比innodb慢。
http://www.bkjia.com/phpjc/326869.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/326869.htmltecharticle一切源于一个实验,请看下面的例子: 表: 复制代码 代码如下: create table if not exists `foo` ( `a` int(10) unsigned not null auto_increment, `b` int(10) u...
