Translate

What is Clustered and Non-Clustered Index?

Clustered and Non-Clustered INDEX

Clustered index is unique for any given table and we can have only one clustered index on a table. The leaf level of a clustered index is the actual data and the data is resorted in case of clustered index. In case of non-clustered index, the leaf level is actually a pointer to the data in rows so we can have as many non-clustered indexes as we can on the db.


Clustered indexes
  • Physically stored in order (ascending or descending) 
  • Only one per table 
  • When a primary key is created a clustered index is automatically created as well. 
  • If the table is under heavy data modifications or the primary key is used for searches, a clustered index on the primary key is recommended. 
  • Columns with values that will not change at all or very seldom, are the best choices. 
  • The clustered index keys are used for searching therefore clustered index keys should be chosen with a minimal length. 
Non-clustered indexes
  • Up to 249 Non-clustered indexes are possible for each table or indexed view. 
  • Covered queries (all the columns used for joining, sorting or filtering are indexed) should be non-clustered. 
  • Foreign keys should be non-clustered.
  • If the table is under heavy data retrieval from fields other than the primary key, one clustered index and/or one or more non-clustered indexes should be created for the column(s) used to retrieve the data.


For more details on Indexes and it's Types, you can check the below post-
http://tipsfororacle.blogspot.in/2016/09/oracle-indexes.html

3 comments:

  1. Is clustered and non clustered indexes is Oracle concept or its SQL server concept

    ReplyDelete
  2. can you please provide more scenario and example for suitable syntaxes in Oracle DB

    ReplyDelete