在MySql和PHP中插入随机数据以进行基准测试 [英] Insert random data in MySql and PHP for benchmark

查看:58
本文介绍了在MySql和PHP中插入随机数据以进行基准测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有用于MySQL/php基准测试的(免费)工具.

I was wondering if there is a (free) tool for mysql/php benchmark.

特别是,我想将成千上万的数据插入MySQL数据库,并通过并发查询测试应用程序以查看其是否可持续.这是在最坏的情况下测试应用程序.

In particular, I would like to insert thousands of data into the MySQL database, and test the application with concurrent queries to see if it will last. This is, test the application in the worst cases.

我看到了一些付费工具,但没有一个免费或可定制的工具.

I saw some pay tools, but none free or customizable one.

有什么建议吗?或任何脚本?

Any suggestion? or any script?

Thnx

推荐答案

将一条记录插入表中.

然后做:

INSERT IGNORE INTO table SELECT FLOOR(RAND()*100000) FROM table;

然后多次运行该行.每次您将表中的行数加倍(并且加倍非常快).这比用PHP或其他代码生成数据快很多.您可以修改从中选择RAND()的列,以及数字的范围.也可以随机生成文本,但是需要更多工作.

Then run that line several times. Each time you will double the number of rows in the table (and doubling grows VERY fast). This is a LOT faster than generating the data in PHP or other code. You can modify which columns you select RAND() from, and what the range of the numbers is. It's possible to randomly generate text too, but more work.

您可以一次从多个终端运行此代码以测试并发插入. IGNORE将忽略任何主键冲突.

You can run this code from several terminals at once to test concurrent inserts. The IGNORE will ignore any primary key collisions.

这篇关于在MySql和PHP中插入随机数据以进行基准测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆