oracle 范围扫描 vs 唯一扫描 vs 跳过扫描
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17710771/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Range scan vs Unique Scan vs Skip Scan
提问by Bharath ABK
What does unique scan, range scan and skip scan mean? Can we explicitly decide which scan to use? What are the pros and cons of all these scans?
唯一扫描、范围扫描和跳过扫描是什么意思?我们可以明确决定使用哪种扫描吗?所有这些扫描的优缺点是什么?
回答by Curt
These are pretty self-explanatory by their name:
这些名称一目了然:
A "unique" scan scans for a single value in a unique index.
A "range" scan starts at some starting value, and reads index entries sequentially (i,.e. along the b-tree) until it encounters a value that runs past a second value (a search for a single value on a non-unique index is a range scan, BTW).
A "skip" scan uses only the leading column(s) of a composite index to work out its distinct values (so, once it finds a value, it "skips" along that index until it finds the next one).
“唯一”扫描扫描唯一索引中的单个值。
“范围”扫描从某个起始值开始,并按顺序(即沿 b 树)读取索引条目,直到遇到一个超过第二个值的值(在非唯一索引是范围扫描,顺便说一句)。
“跳过”扫描仅使用复合索引的前导列来计算其不同的值(因此,一旦找到一个值,它就会沿着该索引“跳过”,直到找到下一个值)。
Each is appropriate (and optimal) for a given type of record matching. The SQL optimizer almost always picks the most appropriate for a given situation (if statistics are up-to-date).
对于给定类型的记录匹配,每个都是合适的(并且是最佳的)。SQL 优化器几乎总是为给定的情况选择最合适的(如果统计数据是最新的)。