首頁  >  問答  >  主體

mysql - 数据库批量插入数据的速度是否与索引有关?

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

伊谢尔伦伊谢尔伦2741 天前597

全部回覆(2)我來回復

  • 伊谢尔伦

    伊谢尔伦2017-04-17 16:14:56

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

    回覆
    0
  • 高洛峰

    高洛峰2017-04-17 16:14:56

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

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

    回覆
    0
  • 取消回覆