Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Primary index vs Clustered index

Tags:

indexing

Is it correct to say that clustered index is an index on a non-key value of a table of records while the records are sorted based on that attribute? Where as primary index is on an attribute that is a key for that table of records and table is sorted based on that attribute?

like image 885
user1836957 Avatar asked Sep 07 '25 20:09

user1836957


1 Answers

A clustered index is a special type of index that reorders the way records in the table are physically stored. Therefore table can have only one clustered index. The leaf nodes of a clustered index contain the data pages.

A primary index is an index on a set of fields that includes the unique primary key for the field and is guaranteed not to contain duplicates.

Primary key is not necessarily clustered index (although probably in 95% of scenarios it is), while Clustered index is not necessarily is primary key.

like image 121
Renats Stozkovs Avatar answered Sep 11 '25 00:09

Renats Stozkovs