影响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及导入性能的影响的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 让8只数码管从左往右显示1、2、3、4、
- 下一篇: java 类 解析_Java集合类解析