国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

mysql - 數(shù)據(jù)庫批量插入數(shù)據(jù)的速度是否與索引有關(guān)?

瀏覽:154日期:2022-06-16 09:46:08

問題描述

在數(shù)據(jù)庫批量插入數(shù)據(jù)時,插入數(shù)據(jù)的速度是否與創(chuàng)建的索引有關(guān)?如果有關(guān)請給出指相關(guān)文檔,謝謝!

問題解答

回答1:

當然會有影響,插入數(shù)據(jù)的時候會導(dǎo)致索性的更新。索性越多,插入會越慢。可以看文檔描述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:

索引對批量插入數(shù)據(jù)的影響非常大,道理很簡單,一方面是寫表的時候需要同時寫索引,另外就對于唯一索引需要檢查數(shù)據(jù)是否有重復(fù)。

對于大批量的數(shù)據(jù)導(dǎo)入,一般都是先把索引去掉,等數(shù)據(jù)導(dǎo)入完成后再重建索引。

相關(guān)文章:
主站蜘蛛池模板: 淅川县| 绥宁县| 松滋市| 夏津县| 登封市| 香港 | 嘉禾县| 宜良县| 和林格尔县| 灵川县| 绥宁县| 古蔺县| 上高县| 奎屯市| 新平| 肥乡县| 南漳县| 神木县| 安多县| 称多县| 鄱阳县| 大荔县| 泗阳县| 吉水县| 湄潭县| 五寨县| 江阴市| 镇安县| 乡城县| 新晃| 水城县| 临泉县| 天峨县| 东乡| 宜章县| 鸡泽县| 兖州市| 拜泉县| 松潘县| 威远县| 富阳市|