一切源于一个实验,请看下面的例子:
表:
我往两个表中插入了30w的数据(插入的时候性能差别InnoDB比MyISAM慢)

一次查询就会差别这么多!!InnoDB和MyISAM,赶紧分析分析为什么。
首先是使用explain来进行查看

确定两边都没有使用index,第二个查询查的rows,并且MyISAM的查询rows还比InnoDB少这么多,反而是查询慢于InnoDB!!这Y的有点奇怪。
没事,还有一个牛掰工具profile
请注意以下说明:1、本程序允许任何人免费使用。2、本程序采用PHP+MYSQL架构编写。并且经过ZEND加密,所以运行环境需要有ZEND引擎支持。3、需要售后服务的,请与本作者联系,联系方式见下方。4、本程序还可以与您的网站想整合,可以实现用户在线服务功能,可以让客户管理自己的信息,可以查询自己的订单状况。以及返点信息等相关客户利益的信息。这个功能可提高客户的向心度。安装方法:1、解压本系统,放在
0
具体使用可以参考:http://dev.mysql.com/doc/refman/5.0/en/show-profile.html
使用方法简单来说:

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慢。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号