unique clustered index

But whenever possible have a unique clustered index.  For example, on the state codes table, a unique clustered index on state_code would work just fine.
i am reading as above.
what is meaning of unique clustered index and how it is different from regular index. please let me know advantages of using it.

please advise
LVL 7
gudii9Asked:
Who is Participating?
 
PortletPaulConnect With a Mentor freelancerCommented:
A clustered index determines how the data is organized on disk which is why you can only have one clustered index for a table.

You can create a clustered index on one or more columns that permits duplication of values within that column or columns. Such a  clustered index does not constrain you from adding non-unique key data in the columns of that index.

Alternatively a unique clustered index is formed by one or more columns that contains no duplicates. Such an index, made with the "unique" keyword, means that this type of index does not permit non unique data in the column(s) of that index.

additional note:
Because a clustered index is used as the way data is stored, the clustered index must know how to identify each row. So for a non-unique clustered index a 4 byte unique identifier is added to the index so it can locate each row. This is internal only, not seen by users.
2
 
slightwv (䄆 Netminder) Commented:
I would start with the documentation and ask questions about the specifics that you do not understand:
https://docs.microsoft.com/en-us/sql/relational-databases/indexes/clustered-and-nonclustered-indexes-described
0
 
gudii9Author Commented:
i read less the unique clustered index number slow at data access where as more the number slow down data modification which was not clear either.

please advise
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
wilcoxonConnect With a Mentor Commented:
To expand on what PortletPaul said:

A clustered index stores the data on disk in the index order.

Unique is a separate index qualifier (it can be used on clustered and non-clustered indexes).  It simply says that each set of index fields must be unique.

A unique clustered index can be thought of as the primary key of the table (and, in older versions of Sybase, this worked much better than actually declaring primary keys).

Since a clustered index determines how the table is physically stored, lookups are very fast (with most indexes, the index stores a pointer into the table for each index entry - with a clustered index, the index entry is the table data).  On the flip side, since the table is physically stored in the index order, inserts or updates may require reordering the physical table.
2
 
PortletPaulfreelancerCommented:
>>"i read less the unique clustered index number slow at data access where as more the number slow down data modification which was not clear either."

A unique clustered index is fast for data access (if a query is able to use that index).

A table can only have one clustered index, but it can have many additional non-clustered indexes.
When a table has many indexes, inserts/updates into that table may get slower because the database needs to refresh many indexes.

Plus, as wilcoxon has already mentioned, a clustered index can also slow down inserts/updates too:
"... since the table is physically stored in the [clustered] index order, inserts or updates may require reordering the physical table."

Think of it this way:
To make a car faster we remove weight which can make it less safe.
There is a "trade-off" between speed and safety.

Indexes do help to make data access faster, but the "trade-off" can be slower inserts/updates.
0
 
David FavorConnect With a Mentor Linux/LXD/WordPress/Hosting SavantCommented:
Normally a unique cluster index is a unique number associated with each node in your cluster.

These values are used for debugging, so you can tell which unique cluster node actually created the row of data in question.

Without this indicator, there's no way to determine which node created which data row.
0
 
wilcoxonCommented:
Split the points between all people that replied with relevant information.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.