October 27, 2009 at 5:10 am
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
October 27, 2009 at 5:14 am
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
October 27, 2009 at 6:21 am
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
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
January 16, 2010 at 4:33 pm
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?
January 16, 2010 at 8:42 pm
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?
January 17, 2010 at 2:19 am
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
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply