mysql - 数据库批量插入数据的速度是否与索引有关?
伊谢尔伦
伊谢尔伦 2017-04-17 16:12:56
0
2
636

在数据库批量插入数据时,插入数据的速度是否与创建的索引有关?
如果有关请给出指相关文档,谢谢!

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

全部回覆(2)
伊谢尔伦

當然會有影響,插入資料的時候會導致索性的更新。索性越多,插入會越慢。可以看文件描述
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 indextimal set of indextimal set of indextimal set of indextimal set of indextimal set of indextimal set of indextimal set of indextimal set of indextimal set of indextimal set of indextimal set of indextimal set of indextimal set of indextimal set of indextimal set of indextimal set of indextimal set of indextimal set of indextimal set of indextimal set.

小葫芦

索引對批次插入資料的影響非常大,道理很簡單,一方面是寫表的時候需要同時寫索引,另外就對於唯一索引需要檢查資料是否有重複。

對於大批量的資料導入,一般都是先把索引去掉,等資料導入完成後再重建索引。

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板