Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Physical and Logical Ordering of an index


Physical and Logical Ordering of an index

Author
Message
Chandhini
Chandhini
Valued Member
Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)

Group: General Forum Members
Points: 57 Visits: 211
Hi,

Fragmentation will occur if physical and logical order are different..

but there is a confusion, what exactly are we referring physical order and logical order?

My understand of them,
Physical Order : Contiguous pages
Chandhini
Chandhini
Valued Member
Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)

Group: General Forum Members
Points: 57 Visits: 211
Hi,

Fragmentation will occur if physical and logical order are different..

but there is a confusion, what exactly are we referring physical order and logical order?

My understand of them,
Physical Order : Contiguous pages

and logical order : data pages are linked like a linked list. and references would be there for physical order.

Is that correct. please guide me if i m wrong.

Regards,
Ramani
Grant Fritchey
Grant Fritchey
SSC-Insane
SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)

Group: General Forum Members
Points: 20819 Visits: 32385
Logical order is the ordering of the index. Let's assume an index based on last name. The logical order would be:

Adams
Johnson
Smith
Williams

But, due to page splits, insertions, deletes and the other things that can affect the order in which pages or stored, the physical order, meaning the order of the actual storage, may look like this:

Adams
Wiliam
Johnson
Smith

Defragmenting will move the order of the physical storage closer to that of the logical definition. It may not be exact and it's unlikely to remain so as the data changes.

----------------------------------------------------
The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
Theodore Roosevelt

The Scary DBA
Author of: SQL Server Query Performance Tuning and SQL Server Execution Plans
Product Evangelist for Red Gate Software
jsb12
jsb12
SSC Rookie
SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)

Group: General Forum Members
Points: 46 Visits: 233
I'm getting it now. I had doubts regarding this.
But still, one more clarification - when it is said that when clustered index is traversed to the leaf level, the data is retrieved not just pointed to. Does this retrieving have any bearing on the physical storage, or how data is physically stored? what implications does this have in terms of logical order vs physical order?
Matt Miller (#4)
Matt Miller (#4)
SSCrazy Eights
SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)

Group: General Forum Members
Points: 8638 Visits: 18284
When there IS a clustered index, the physical data is stored in the clustered index. So the leaf level of a CLUSTERED index = the actual record. Any non-clustered index points to the clustered index for its data, so given your description, in a clustered index the data is retrieved as soon as you access the leaf node, instead of the extra hop (called a "bookmark lookup") you end up with in a non-clustered index.

Keep in mind that even the pages themselves are logical constructs. Granted - they're a fixed size, but they exist within physical files which grow as needed, so you could have multiple kinds of "physical fragementation". For example, with files that grow with "auto-growth on", the files themselves will be fragmented on the OS layer; the pages can physically exist anywhere within those OS files, then getting logically assigned to the index based on the usage and maintenance patterns on the table.

----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
GilaMonster
GilaMonster
SSC Guru
SSC Guru (58K reputation)SSC Guru (58K reputation)SSC Guru (58K reputation)SSC Guru (58K reputation)SSC Guru (58K reputation)SSC Guru (58K reputation)SSC Guru (58K reputation)SSC Guru (58K reputation)

Group: General Forum Members
Points: 58857 Visits: 44718
This series on indexing (and especially the comments on the second one) may be worth reading
http://www.sqlservercentral.com/articles/Indexing/68439/

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search