Hi friends
What is the basic difference between clustered and a non-clustered index? Why we use these type of index.......
thanks..........
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
TulasiRank #2,544 · 549 reputationPosted Nov 23, 2011, 7:03 PM EST
2 Types of Indexes
Clustered Index: we can create only one clustered index for table .
It sort the records either ascendeing order or descendeing order permanatly in database . this is useful when to search particular range of records .
By default Primary key Contraint will create clustered index on table
Non-Clustered Index: can create more than one non-clustered indexes on table.
It will no sort records Physically , this is usefull when to search random records on table . By default unique key contraint will create non-clustered index on table.
Use of SQL server indexes provide many facilities such as:
Chk the below link http://www.codeproject.com/KB/database/SQLIndex.aspx
NarayanRank #8,477 · 221 reputationPosted Nov 23, 2011, 3:48 PM EST
Satyapriya NayakRank #47 · 31.5K reputationPosted Nov 23, 2011, 5:40 PM EST
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.
Clustered index is physically stored a table can have 1 clustered index
A non-Clustered index is a special type of index in which the logical order of the index does not match the physical stored order of the rows on disk. The leaf node of a non-Clustered index does not consist of the data pages. Instead, the leaf nodes contain index rows.
Non clustered index is logically stored a table can have 249 non Clustered indexThanks
AartiRank #2,383 · 594 reputationPosted Nov 23, 2011, 6:32 PM EST
Clustered indexes cause the data to be ordered according to the index,
which means reordering happens every time the index changes, for whatever
reason. Could be an UPDATE, or an INSERT.
Since clustering affects the physical order of data, a table can have a
maximum of 1 clustered index.
The general rule of thumb is to:
1: cluster on columns where you fetch ranges
2: cluster on columns you frequently order by
3: cluster on primary key. Of dubious value in my opinion.
One main and importtant difference is that when a table doesn't hava a clustered index,
any non-clustered index contain a pointer to the actual data in the
table. When a clustered index is created, all non-clustered indexes are
rebuilt to contain the index columns of the clustered index, which may
lead to slower access.
Quite often, it's more valuable to consider creating covering indexes,
i.e. an index containing all columns required to run a query, thus
eliminating looking in the actual data pages.
About reclaiming unused space: Yes, rebuilding a non-clustered index
doesn't affect actual table space, but a clustered index *includes* the
data pages, hence the change in space usage when rebuilding the index.
Thanks.
Vikas MishraRank #559 · 4.3K reputationPosted Nov 25, 2011, 6:00 PM EST