我有一个连接数据库的Java应用程序。在生产环境中,数据集非常大,因此应用程序非常慢,我想在开发环境中模拟(缓慢)。有没有办法,如何减慢mysql,所以响应时间更长?
我知道,我可以扩大我的测试数据集,但是大数据集的处理会占用处理器周期,我宁愿在sleep
中搜索能够“廉价”MySQL
的东西。< / p>
答案 0 :(得分:0)
MySQL有一个SLEEP(duration)
杂项函数,其中duration是秒数。
来源:http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#function_sleep
答案 1 :(得分:0)
您可以将MySQL数据库文件复制到(慢,旧)usb密钥,并将MySQL的设置datadir设置为指向usb。我将MySQL数据目录复制到usb键并将datadir变量设置为usb。
#Path to the database root
#datadir="C:/Program Files (x86)/MySQL/MySQL Server 5.0/Data/"
datadir = "E:/data"
我认为将innodb_flush_log_at_trx_commit设置为1非常重要。
# If set to 1, InnoDB will flush (fsync) the transaction logs to the
# disk at each commit, which offers full ACID behavior. If you are
# willing to compromise this safety, and you are running small
# transactions, you may set this to 0 or 2 to reduce disk I/O to the
# logs. Value 0 means that the log is only written to the log file and
# the log file flushed to disk approximately once per second. Value 2
# means the log is written to the log file at each commit, but the log
# file is only flushed to disk approximately once per second.
innodb_flush_log_at_trx_commit=1
这样每次更新,删除,插入语句都会导致I / O刷新。
答案 2 :(得分:0)
要添加到SLEEP()函数注释,这里可以轻松地将睡眠集成到任何SQL查询中,而不能将其作为单独的语句运行:
LEFT JOIN (SELECT SLEEP(30)) as `sleep` ON 1=1