Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Physical and Logical Ordering of an index Expand / Collapse
Author
Message
Posted Tuesday, October 27, 2009 5:10 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC 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
Post #809198
Posted Tuesday, October 27, 2009 5:14 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC 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
Post #809201
Posted Tuesday, October 27, 2009 6:21 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 2:50 PM
Points: 13,752, Visits: 28,150
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
Post #809237
Posted Saturday, January 16, 2010 4:33 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Sunday, January 2, 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?
Post #848787
Posted Saturday, January 16, 2010 8:42 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 2:12 PM
Points: 7,064, Visits: 15,283
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?
Post #848804
Posted Sunday, January 17, 2010 2:19 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 2:25 PM
Points: 39,910, Visits: 36,250
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

Post #848833
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse