|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Tuesday, May 10, 2011 12:15 PM
Points: 35,
Visits: 210
|
|
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
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Tuesday, May 10, 2011 12:15 PM
Points: 35,
Visits: 210
|
|
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
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Yesterday @ 3:57 PM
Points: 13,371,
Visits: 25,152
|
|
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 2012 Query Performance Tuning SQL Server 2008 Query Performance Tuning Distilled and SQL Server Execution Plans
Product Evangelist for Red Gate Software
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Sunday, January 02, 2011 8:17 PM
Points: 30,
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?
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 6:49 PM
Points: 6,998,
Visits: 13,946
|
|
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?
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Yesterday @ 5:49 PM
Points: 37,671,
Visits: 29,925
|
|
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 2008, MVP 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
|
|
|
|