Link to home
Start Free TrialLog in
Avatar of Lawrence Avery
Lawrence AveryFlag for United States of America

asked on

SQL Server -Clustered Indexed tables

Tell me if I have the concept down on Clustered Index tables:

The actual clustered Indexes are arranged in order by index value ( physically) on a page with each having a  pointer to a leaf page where the data resides. The data rows in the leaf pages are not physically stored in the same order has the index but are stored in chained pages.
Avatar of PortletPaul
PortletPaul
Flag of Australia image

A clustered index sorts and stores the data rows of the table or view in order based on the clustered index key. The clustered index is implemented as a B-tree index structure that supports fast retrieval of the rows, based on their clustered index key values.
http://msdn.microsoft.com/en-us/library/ms175049.aspx

i.e. I don't believe your description is accurate.
(that description is more akin to a non-clustered index - see your other question)
Each index row in the nonclustered index contains the nonclustered key value and a row locator.
Avatar of Lawrence Avery

ASKER

I guess what I am really getting at is the Leaf Node of the clustered index table. Say you have a leaf node page with a  index key range of 100 to 150. meaning the clustered index values range from 100 to 150. The arranged data rows in that leaf node page can be arranged like so
100
130
120
150 etc In other words the rows in the Leaf node are not necessarily physically stored in order by the index but that the leaf node page contains that range of values.
See https://www.simple-talk.com/sql/learn-sql-server/sql-server-index-basics/
what I mean by physically order by index
100
120
130
150
Forget I mentioned a pointer to the leaf node page. The process is traversing the BTree to get to a range of index values and then getting to that range on the leaf (100-150) and searching within that range.

I just read in my MCTS Exam 70-432  MS SQL Server 2008 Implementation and Maintenance book that a clustered index does not physically store the data on disk in a sorted order  because doing so creates a large amount of disk I/O for page split operations. Instead, a clustered ensures that the page chain of the index is sorted logically, allowing SQL Server to traverse directly down the page chain to locate data.
ok, understand your question better now
certainly the clustered index nodes store the related data (and the index itself is sorted) - that bit you know

Is the data within a node physically sorted?  - if the clustered index design arrived at uniqueness then by inference the data would be (as result of the sorted index) - if however a clustered index didn't arrive at uniqueness - then your question arises
(and that bit I don't know I'm afraid, as I've never looked that far into it, I'm more interested in logic and less interested in the physical arrangement, others do that for me:)

There  are other experts here with that style of knowledge
ASKER CERTIFIED SOLUTION
Avatar of DcpKing
DcpKing
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Mike,
That makes sense. Great answer.

 Larry