myisam和innodb读写性能对比

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介:
网上有很多评论myisam和innodb读写性能对比。

读myisam要比innodb要快,为啥快?

我的论点是:myisam直接从磁盘里拿数据,而innodb要分两步,innodb要从内存里首先获取数据,如果没有再到磁盘里拿。而且一开始innodb要有个加热的过程,也就是说,内存里的数据不是一下子就缓存,而是一点一点的缓存那些热数据。如果你的内存小,数据库里的数据量要大于buffer_pool_size设置的值,并发较低,性能就下降。

这也就解释了在这个场景里,读myisam要比innodb要快。

innodb玩的是内存,内存越大,它的优势才能发挥出来。
myisam玩的是硬盘IO,转速越快,它的优势才能发挥出来。

数据库做RAID10较合适。


大并发测试
innodb_buffer_pool_size=11G
sync_binlog=0
innodb_flush_log_at_trx_commit = 0
mysql 5.1.43 + innodb_plugin 1.0.6

[root@test ~]# sysbench --test=oltp  --mysql-table-engine=innodb  --oltp-table-size=1000000 --max-requests=10000 --num-threads=100 --mysql-host=192.168.1.11    --mysql-port=3306 --mysql-user=admin --mysql-password=admin123 --mysql-db=test --mysql-socket=/tmp/mysql.sock run
sysbench 0.4.12:  multi-threaded system evaluation benchmark

No DB drivers specified, using mysql
Running the test with following options:
Number of threads: 100

Doing OLTP test.
Running mixed OLTP test
Using Special distribution (12 iterations,  1 pct of values are returned in 75 pct cases)
Using "BEGIN" for starting transactions
Using auto_inc on the id column
Maximum number of requests for OLTP test is limited to 10000
Threads started!
Done.

OLTP test statistics:
    queries performed:
        read:                            140014
        write:                           50005
        other:                           20002
        total:                           210021
    transactions:                        10001  (1549.15 per sec.)
    deadlocks:                           0      (0.00 per sec.)
    read/write requests:                 190019 (29433.80 per sec.)
    other operations:                    20002  (3098.29 per sec.)

Test execution summary:
    total time:                          6.4558s
    total number of events:              10001
    total time taken by event execution: 643.9687
    per-request statistics:
         min:                                  9.24ms
         avg:                                 64.39ms
         max:                                450.00ms
         approx.  95 percentile:             150.97ms


Threads fairness:
    events (avg/stddev):           100.0100/6.69
    execution time (avg/stddev):   6.4397/0.01

========================================================================================================

[root@test ~]# sysbench --test=oltp  --mysql-table-engine=myisam  --oltp-table-size=1000000 --max-requests=10000 --num-threads=100 --mysql-host=192.168.1.11    --mysql-port=3306 --mysql-user=admin --mysql-password=admin123 --mysql-db=test --mysql-socket=/tmp/mysql.sock run
sysbench 0.4.12:  multi-threaded system evaluation benchmark

No DB drivers specified, using mysql
Running the test with following options:
Number of threads: 100

Doing OLTP test.
Running mixed OLTP test
Using Special distribution (12 iterations,  1 pct of values are returned in 75 pct cases)
Using "LOCK TABLES WRITE" for starting transactions
Using auto_inc on the id column
Maximum number of requests for OLTP test is limited to 10000
Threads started!
Done.

OLTP test statistics:
    queries performed:
        read:                            140000
        write:                           50000
        other:                           20000
        total:                           210000
    transactions:                        10000  (154.54 per sec.)
    deadlocks:                           0      (0.00 per sec.)
    read/write requests:                 190000 (2936.22 per sec.)
    other operations:                    20000  (309.08 per sec.)

Test execution summary:
    total time:                          64.7090s
    total number of events:              10000
    total time taken by event execution: 6436.0518
    per-request statistics:
         min:                                  9.72ms
         avg:                                643.61ms
         max:                                738.83ms
         approx.  95 percentile:             665.96ms


Threads fairness:
    events (avg/stddev):           100.0000/0.00
    execution time (avg/stddev):   64.3605/0.19

======================================================================

在大并发情况下,innodb的性能体现出来了。


本文转自 liang3391 51CTO博客,原文链接:http://blog.51cto.com/liang3391/729829


相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
2月前
|
存储 安全 关系型数据库
|
2月前
|
存储 缓存 关系型数据库
MySQL - 存储引擎MyISAM和Innodb
MySQL - 存储引擎MyISAM和Innodb
|
13天前
|
存储 关系型数据库 MySQL
MySQL引擎对决:深入解析MyISAM和InnoDB的区别
MySQL引擎对决:深入解析MyISAM和InnoDB的区别
28 0
|
4月前
|
存储 SQL 关系型数据库
MySQL存储引擎之MyISAM和InnoDB
MySQL存储引擎之MyISAM和InnoDB
46 0
|
3月前
|
存储 关系型数据库 MySQL
MySQL存储引擎 InnoDB、MyISAM、Memory存储引擎的特点与区别
MySQL存储引擎 InnoDB、MyISAM、Memory存储引擎的特点与区别
56 0
|
4月前
|
存储 关系型数据库 MySQL
⑩【MySQL】存储引擎详解, InnoDB、MyISAM、Memory。
⑩【MySQL】存储引擎详解, InnoDB、MyISAM、Memory。
38 0
|
4月前
|
存储 关系型数据库 MySQL
MySQL 中InnoDB与MyISAM的区别是什么?
MySQL 中InnoDB与MyISAM的区别是什么?
64 0
MySQL 中InnoDB与MyISAM的区别是什么?
|
4月前
|
存储 关系型数据库 MySQL
MySQL ⽀持哪些存储引擎?默认使⽤哪个?MyISAM 和 InnoDB 引擎有什么区别,如何选择?
MySQL ⽀持哪些存储引擎?默认使⽤哪个?MyISAM 和 InnoDB 引擎有什么区别,如何选择?
|
4月前
|
存储 关系型数据库 MySQL
InnoDB和MyISAM存储引擎对比
InnoDB和MyISAM存储引擎对比 相同点:都是B+索引,不清楚B+索引的可以看上一篇
40 1
|
5月前
|
存储 SQL 关系型数据库
MySQL的InnoDB和MyISAM区别
MySQL的InnoDB和MyISAM区别
34 0