文章詳情頁
mysql - 數據庫批量插入數據的速度是否與索引有關?
瀏覽:129日期:2022-06-16 09:46:08
問題描述
在數據庫批量插入數據時,插入數據的速度是否與創建的索引有關?如果有關請給出指相關文檔,謝謝!
問題解答
回答1:當然會有影響,插入數據的時候會導致索性的更新。索性越多,插入會越慢??梢钥次臋n描述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. angular.js - angularjs如何傳遞id給另一個視圖 根據id獲取json數據?2. java - HashSet<int> 為何有錯誤?3. mysql - 記得以前在哪里看過一個估算時間的網站4. 使用text-shadow可以給圖片加陰影嗎?5. docker start -a dockername 老是卡住,什么情況?6. nginx啟用gzip壓縮后,文件尺寸無變化.7. java - StringBuffer轉成String,可以不同過tostring,而是通過+“”的方式轉換嗎?8. 數據庫無法進入9. docker images顯示的鏡像過多,狗眼被亮瞎了,怎么辦?10. 在windows下安裝docker Toolbox 啟動Docker Quickstart Terminal 失??!
排行榜
