Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unique vs non-unique index

Tags:

sql

oracle

plsql

My table holds nearly 40+ million records., with 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

like image 831
BalaB Avatar asked Dec 11 '13 09:12

BalaB


1 Answers

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.

like image 125
Jeffrey Kemp Avatar answered Sep 29 '22 16:09

Jeffrey Kemp