2011-09-28 51 views
0

我有一個連接到數據庫的Java應用程序。在生產環境中,數據集非常大,所以應用程序非常慢,我想在開發環境中模擬(緩慢)。有沒有辦法,如何減慢mysql,所以響應時間更長?
我知道,我可以放大我的測試數據集,但大數據集的處理會佔用處理器週期,我寧願在MySQL中尋找「便宜」sleep s。mysql故意放緩

+1

的MySQL實際上有睡眠:HTTP ://stackoverflow.com/questions/4284524/how-and-when-to-use-sleep-correctly-in-mysql – Konerak

回答

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沖洗是很重要的。

0

要添加到SLEEP()函數評論,下面是睡眠集成到任何SQL查詢時,您不能運行它作爲單獨的聲明一個簡單的方法:

LEFT JOIN (SELECT SLEEP(30)) as `sleep` ON 1=1