文章詳情頁
mysql - 數據庫批量插入數據的速度是否與索引有關?
瀏覽:258日期:2022-06-16 09:46:08
問題描述
在數據庫批量插入數據時,插入數據的速度是否與創(chuàng)建的索引有關?如果有關請給出指相關文檔,謝謝!
問題解答
回答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. nignx - docker內nginx 80端口被占用2. docker容器呢SSH為什么連不通呢?3. javascript - 連續(xù)點擊觸發(fā)mouseleave事件4. docker - 各位電腦上有多少個容器啊?容器一多,自己都搞混了,咋辦呢?5. 關于docker下的nginx壓力測試6. 關docker hub上有些鏡像的tag被標記““This image has vulnerabilities””7. mac里的docker如何命令行開啟呢?8. docker gitlab 如何git clone?9. dockerfile - 我用docker build的時候出現(xiàn)下邊問題 麻煩幫我看一下10. angular.js使用$resource服務把數據存入mongodb的問題。
排行榜

網公網安備