日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql 插入记录慢_mysql:insert插入数据过慢如何解决,设置innodb_flush_log_at_trx_commit为0就能解决...

發布時間:2023/12/15 数据库 47 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql 插入记录慢_mysql:insert插入数据过慢如何解决,设置innodb_flush_log_at_trx_commit为0就能解决... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

問題:

最近在做性能測試,造數據,發現insert好慢,只有幾十條每秒,很奇怪,最后再網上找到了原因。

網文如下:

MY SQL insert 速度過慢

最近在用MySQL做存儲,測試中發現插入數據太慢了,插入速度只有20-30 條/秒,后來查資料后,將MySQL的1個參數:innodb_flush_log_at_trx_commit,1改為了0(修改方法,可以直接修改my.ini(windows)/my.cnf(linux)中的對應參數,似乎用命令直接設置沒有效果),插入速度就提升到了3000+每S,MySQL的文檔中,對這個參數的描述如下:

If the value of innodb_flush_log_at_trx_commit is 0, the log buffer is written out to the log file once per second and the flush to disk operation is performed on the log file, but nothing is done at a transaction commit. When the value is 1 (the default),

the log buffer is written out to the log file at each transaction commit and the flush to disk operation is performed on the log file. When the value is 2, the log buffer is written out to the file at each commit, but the flush to disk operation is not performed

on it. However, the flushing on the log file takes place once per second also when the value is 2. Note that the once-per-second flushing is not 100% guaranteed to happen every second, due to process scheduling issues.

這樣,如果transaction commit的頻率非常高,1秒鐘內會進行很多次的話,可以考慮將其設置為0,但這樣就要承擔數據庫Crash后,1秒內未存儲到數據庫數據丟失可能的風險

設置后重啟mysql,再重新執行存儲過程,基本上插入速度能達到6000條/s。

總結

以上是生活随笔為你收集整理的mysql 插入记录慢_mysql:insert插入数据过慢如何解决,设置innodb_flush_log_at_trx_commit为0就能解决...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。