影响mysql导入效率的参数_extended-insert对mysqldump及导入性能的影响
參數(shù)說明:
-e, --extended-insert,長(zhǎng)INSERT,多row在一起批量INSERT,提高導(dǎo)入效率,和沒有開啟 -e 的備份導(dǎo)入耗時(shí)至少相差3、4倍,默認(rèn)開啟;用--extended-insert=false關(guān)閉。強(qiáng)烈建議開啟,通過下面的測(cè)試比較就會(huì)明白為什么了。
一、默認(rèn)方式導(dǎo)出,也即--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
二、采用參數(shù)--extended-insert=false導(dǎo)出全庫(kù):
[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
三、對(duì)比到處的sql文件的大小不一樣:
[root@localhost ~]# du -sh testdump.sql? 1testdump.sql 2testdump.sql
414M?? ?testdump.sql
414M?? ?1testdump.sql
550M?? ?2testdump.sql
四、對(duì)比恢復(fù)到數(shù)據(jù)庫(kù)所用的時(shí)間:
[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
經(jīng)過上面的一比較,發(fā)現(xiàn)導(dǎo)入速度相差非常多。
但是使用--extended-insert=false導(dǎo)出表也有好處
比如數(shù)據(jù)庫(kù)中表中已經(jīng)存在大量數(shù)據(jù),那么再往表中導(dǎo)入數(shù)據(jù)時(shí),如果出現(xiàn)主鍵數(shù)據(jù)沖突Duplicate key error,將會(huì)導(dǎo)致導(dǎo)入操作失敗,但此時(shí)如果是使用--extended-insert=false導(dǎo)出表,導(dǎo)入時(shí)主鍵沖突的會(huì)報(bào)錯(cuò)Duplicate key error,但不沖突的數(shù)據(jù)仍然能正常導(dǎo)入。
總結(jié)
以上是生活随笔為你收集整理的影响mysql导入效率的参数_extended-insert对mysqldump及导入性能的影响的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 让8只数码管从左往右显示1、2、3、4、
- 下一篇: java 类 解析_Java集合类解析