mysql自带的性能测试工具mysqlslap

想测试一下mysql的性能,可以使用它自带的工具mysqlslap
文档是 http://dev.mysql.com/doc/refman/5.1/en/mysqlslap.html
在mysql的配置文件里可以加入如下section

[mysqlslap]
query="D:/mysql-5.1.63-node1/mysqlslap-query.sql"
create-schema="crap"
delimiter=";"
concurrency=10
iterations=3

mysqlslap-query.sql这个文件包含了要执行的query语句,用";"分割
引用

select SQL_NO_CACHE * from 20130122handler where uid=26010200;
select SQL_NO_CACHE * from 20130122handler where uid=23742985;

然后.\mysqlslap.exe -u root -proot 这个命令就可以执行了
输出如下

Benchmark
        Average number of seconds to run all queries: 0.015 seconds
        Minimum number of seconds to run all queries: 0.015 seconds
        Maximum number of seconds to run all queries: 0.016 seconds
        Number of clients running queries: 10
        Average number of queries per client: 2
      
运行之前可以用.\mysqlslap.exe -u root -proot --only-print预览要执行的语句

另外吐槽下mysql的文档,"create-schema"这个名字真misleading,它文档上说是
"The schema in which to run the tests."

但是如果你同时指定了create,它就把指定的schema drop掉了.......
所以--only-print真是必不可少的.

你可能感兴趣的:(mysql)