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

歡迎訪問 生活随笔!

生活随笔

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

数据库

影响mysql导入效率的参数_extended-insert对mysqldump及导入性能的影响

發布時間:2025/3/12 数据库 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 影响mysql导入效率的参数_extended-insert对mysqldump及导入性能的影响 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

參數說明:

-e, --extended-insert,長INSERT,多row在一起批量INSERT,提高導入效率,和沒有開啟 -e 的備份導入耗時至少相差3、4倍,默認開啟;用--extended-insert=false關閉。強烈建議開啟,通過下面的測試比較就會明白為什么了。

一、默認方式導出,也即--extended-insert=true

[root@localhost ~]# time mysqldump -S /tmp/mysql3307.sock -uroot -p'Zhkj@554996' --single-transaction --extended-insert=true -B -A >testdump.sql

Warning: Using a password on the command line interface can be insecure.

real?? ?0m12.965s

user?? ?0m6.579s

sys?? ?0m1.080s

[root@localhost ~]#

[root@localhost ~]#

[root@localhost ~]# time mysqldump -S /tmp/mysql3307.sock -uroot -p'Zhkj@554996' --single-transaction? -B -A >1testdump.sql

Warning: Using a password on the command line interface can be insecure.

real?? ?0m13.385s

user?? ?0m6.545s

sys?? ?0m1.171s

二、采用參數--extended-insert=false導出全庫:

[root@localhost ~]# time mysqldump -S /tmp/mysql3307.sock -uroot -p'Zykj@554996' --single-transaction --extended-insert=false -B -A >2testdump.sql

Warning: Using a password on the command line interface can be insecure.

real?? ?0m16.216s

user?? ?0m8.820s

sys?? ?0m1.282s

三、對比到處的sql文件的大小不一樣:

[root@localhost ~]# du -sh testdump.sql? 1testdump.sql 2testdump.sql

414M?? ?testdump.sql

414M?? ?1testdump.sql

550M?? ?2testdump.sql

四、對比恢復到數據庫所用的時間:

[root@localhost ~]# time mysql -uroot -p -S /tmp/mysql3307.sock < testdump.sql

Enter password:

real?? ?3m34.245s

user?? ?0m9.018s

sys?? ?0m0.361s

[root@localhost ~]# time mysql -uroot -p -S /tmp/mysql3307.sock < 2testdump.sql

Enter password:

real?? ?46m51.702s

user?? ?0m44.712s

sys?? ?0m35.717s

經過上面的一比較,發現導入速度相差非常多。

但是使用--extended-insert=false導出表也有好處

比如數據庫中表中已經存在大量數據,那么再往表中導入數據時,如果出現主鍵數據沖突Duplicate key error,將會導致導入操作失敗,但此時如果是使用--extended-insert=false導出表,導入時主鍵沖突的會報錯Duplicate key error,但不沖突的數據仍然能正常導入。

總結

以上是生活随笔為你收集整理的影响mysql导入效率的参数_extended-insert对mysqldump及导入性能的影响的全部內容,希望文章能夠幫你解決所遇到的問題。

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