?
Solved

SQL Server -Clustered Indexed tables

Posted on 2013-06-13
5
Medium Priority
?
341 Views
Last Modified: 2013-06-13
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.
0
Comment
Question by:metro156
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 49

Expert Comment

by:PortletPaul
ID: 39246401
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.
0
 

Author Comment

by:metro156
ID: 39246414
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.
0
 
LVL 49

Expert Comment

by:PortletPaul
ID: 39246438
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
0
 
LVL 16

Accepted Solution

by:
DcpKing earned 2000 total points
ID: 39246509
Metro,

Here's possibly the best explanation:

Basically, a page contains rows and a row index array to tell the DBMS where each row starts in the page. If you consider that a clustered index literally keeps things in order then you might expect to find rows 7, 8, and 9 on a page, and the row index array should show 7, 8, 9 in that order. In fact while those three rows will exist in the page, and the row index array will say "7, 8, 9", it's quite possible to have the rows in any physical order within the page - the DBMS goes to the row index array to find the offset within the page of the row, so it incurs no delay no matter where the row is in the  page.

hth

Mike
0
 

Author Closing Comment

by:metro156
ID: 39246586
Mike,
That makes sense. Great answer.

 Larry
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question