久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

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

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

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

問(wèn)題描述

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

問(wèn)題解答

回答1:

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

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

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

相關(guān)文章:
主站蜘蛛池模板: 五原县| 辽宁省| 邵武市| 全南县| 鄂托克旗| 和龙市| 汝阳县| 合肥市| 滦南县| 疏附县| 阳春市| 六安市| 岫岩| 梅州市| 怀远县| 通城县| 本溪市| 岑溪市| 辛集市| 抚远县| 临澧县| 合江县| 黄龙县| 普兰店市| 涪陵区| 宣汉县| 扬中市| 太和县| 唐山市| 青铜峡市| 农安县| 卓尼县| 乌鲁木齐市| 喜德县| 定安县| 金华市| 化隆| 长宁县| 漠河县| 玛多县| 瑞金市|