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

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

伊谢尔伦
伊谢尔伦

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

répondre à tous(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 indexes.

小葫芦

索引对批量插入数据的影响非常大,道理很简单,一方面是写表的时候需要同时写索引,另外就对于唯一索引需要检查数据是否有重复。

对于大批量的数据导入,一般都是先把索引去掉,等数据导入完成后再重建索引。

Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!