oracle 唯一与非唯一索引
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20515501/
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
Unique vs non-unique index
提问by BalaB
My table holds nearly 40+ million records., with DML.
我的表拥有近 40 多万条记录,使用 DML。
Would like to know which one of these Unique or non-unique index would be better option for implementation. To give better performance.
想知道这些唯一或非唯一索引中的哪一个是更好的实施选择。以提供更好的性能。
Environment : Oracle 11g
环境:Oracle 11g
回答by Jeffrey Kemp
If possible, use a unique index. Otherwise, use a non-unique index.
如果可能,请使用唯一索引。否则,使用非唯一索引。
In other words, if you can use a unique index, you should. If there is any reason why duplicate data might need to be recorded, you don't have a choice anyway.
换句话说,如果您可以使用唯一索引,则应该使用。如果有任何原因可能需要记录重复数据,您无论如何都别无选择。
If the index is guaranteed unique, Oracle can perform certain query plan optimisations that are not possible with a non-unique index - for example, if a unique index is used to probe for a particular value, Oracle can stop processing further index blocks as soon as it finds a match.
如果索引保证唯一,Oracle 可以执行非唯一索引无法实现的某些查询计划优化 - 例如,如果使用唯一索引来探测特定值,Oracle 可以尽快停止处理更多索引块因为它找到了匹配项。
回答by Ashish sinha
this entirely depends on type of the data in the table if it has data where uniqueness is
如果表中的数据具有唯一性,则这完全取决于表中的数据类型
high then use B-tree else use Bitmap index.
高然后使用 B 树否则使用位图索引。