简体   繁体   English

问答问题:在 INDEX 查询中,为什么 SELECT 查询比 SQL 中的其他 UPDATE 或 INSERT 查询快得多?

[英]Question to Answer: In INDEX Query, why the SELECT query is much faster than other UPDATE or INSERT query in SQL?

In INDEX Query, why the SELECT query is much faster than other UPDATE or INSERT query in SQL?在 INDEX 查询中,为什么 SELECT 查询比 SQL 中的其他 UPDATE 或 INSERT 查询快得多?

In simplest, select is pulling data already written.简单来说,select 正在拉取已经写入的数据。 Update and insert have to write the data to the pages and also update indexes, so it needs to traverse all possible indexes of impacted tables.更新和插入必须将数据写入页面并更新索引,因此它需要遍历受影响表的所有可能索引。

Additionally, (credit to obe), select queries can take advantage of the cache if the data is associated with a prior query.此外,(归功于 obe),如果数据与先前的查询相关联,select 查询可以利用缓存。 It does not need to go back to the original data pages / indexes to re-pull the data.它不需要go 回到原来的数据页/索引重新拉取数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM