文章詳情頁
mysql - 數據庫批量插入數據的速度是否與索引有關?
瀏覽:255日期:2022-06-16 09:46:08
問題描述
在數據庫批量插入數據時,插入數據的速度是否與創建的索引有關?如果有關請給出指相關文檔,謝謝!
問題解答
回答1:當然會有影響,插入數據的時候會導致索性的更新。索性越多,插入會越慢。可以看文檔描述Although it can be tempting to create an indexes for every possible column used in a query, unnecessary indexes waste space and waste time for MySQL to determine which indexes to use. Indexes also add to the cost of inserts, updates, and deletes because each index must be updated. You must find the right balance to achieve fast queries using the optimal set of indexes.
回答2:索引對批量插入數據的影響非常大,道理很簡單,一方面是寫表的時候需要同時寫索引,另外就對于唯一索引需要檢查數據是否有重復。
對于大批量的數據導入,一般都是先把索引去掉,等數據導入完成后再重建索引。
相關文章:
1. golang - 用IDE看docker源碼時的小問題2. html - css氣泡,實現“倒三角(不知道算不算三角了)”可透明的。3. phpstudy8.1沒集成mysql-front4. java - 如何點擊按鈕,重新運行(我是初學者)?5. 運行python程序時出現“應用程序發生異常”的內存錯誤?6. 我何時應該在Java中使用JFrame.add(component)和JFrame.getContentPane()。add(component)7. 利用IPMI遠程安裝centos報錯!8. 前端 - @media query 使用出現的問題?9. html5和Flash對抗是什么情況?10. javascript - 請指條明路,angular的$event,在select中卻是undefined?
排行榜

網公網安備