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

Fragmentation of Clustered Primary Key Expand / Collapse
Author
Message
Posted Monday, August 6, 2012 4:46 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Today @ 2:06 AM
Points: 382, Visits: 693
I have a table which has a clustered primary key on one int column, which is an identity (1, 1). The fill factor is 90%. The table has ~330k rows in. If I rebuild it, sys.dm_db_index_physical_stats indicates that its fragmentation is 0%. So far, so good.

However, if I then add rows, the fragmentation increases (from 0%). But I don't understand why - surely as the new rows will have ever-increasing values for the identity column, and as the index is both clustered and based on this column only, won't new values simply be added to the end of all existing ones, meaning no page splits will occur (and hence, no fragmentation)?

I've obviously misunderstood something along the way, so if anybody could enlighten me, I would be very grateful.

Thanks. Julian.

PS No rows are being deleted from the table and none are being updated.
Post #1340507
Posted Monday, August 6, 2012 6:47 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Friday, June 27, 2014 12:43 PM
Points: 13,872, Visits: 9,596
How many rows per page?

- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread

"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Post #1340557
Posted Monday, August 6, 2012 7:12 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, June 27, 2014 8:03 AM
Points: 317, Visits: 1,079
This has been covered recently - may be of some help:

http://www.sqlservercentral.com/Forums/Topic872069-1550-1.aspx
Post #1340587
Posted Monday, August 6, 2012 7:48 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Today @ 2:06 AM
Points: 382, Visits: 693
Thanks for the reference. I'm not sure that explained why you'd get fragmentation on an index consisting solely of an increasing identity column where only inserts were being carried out and no updates.

Or have I missed something? Again.
Post #1340613
Posted Monday, August 6, 2012 2:56 PM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, June 27, 2014 8:03 AM
Points: 317, Visits: 1,079
There's another one here you may not have seen:

http://www.sqlservercentral.com/Forums/Topic952029-391-2.aspx

Seems to go into a bit more depth - again not sure it if it will answer your question...
Post #1340905
Posted Tuesday, August 7, 2012 2:01 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Today @ 2:06 AM
Points: 382, Visits: 693
Oooh yes, that looks like it might be just the ticket. Thanks very much.
Post #1341054
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse