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 12»»

Trying to understand non-clustered index Fragmentation Expand / Collapse
Author
Message
Posted Tuesday, January 22, 2013 11:16 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, April 14, 2014 12:29 PM
Points: 81, Visits: 289
Ive got a large transactional table. its has a clustered index on the 'rowID' column (bigint), which is in great shape (as data isnt ever deleted from the db, but thats another issue for another day).

the non-clustered index on 'fkId' and 'trnDate' is horribly fragmented, at ~90%.

I rebuild it, and the resulting fragmentation is still ~90%. I tried again adjusting the fill-factor and its higher yet. interesting, and the table DOES have 4 'bigint' columns in it. pages show avg free space of 789Kb (which is about 10%, so good to work with)

I am getting this from dm_db_index_physical_Stats, and comparing with results of dbcc showcontig. for good measure I ran a dbcc updateusage (which I know I shouldnt need on sql 2008, but...)

everything I've searched on along these lines leads me to generic stuff about tables with few pages, (this one has over 200k pages) and not quite what im after.

any useful links or tips?

thanks in advance!
Post #1410185
Posted Tuesday, January 22, 2013 11:25 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 7:05 AM
Points: 41,532, Visits: 34,449
How many pages does the nonclustered index have?


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 #1410189
Posted Tuesday, January 22, 2013 11:27 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, April 14, 2014 12:29 PM
Points: 81, Visits: 289
over 218k
Post #1410192
Posted Tuesday, January 22, 2013 11:34 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Yesterday @ 1:29 PM
Points: 1,593, Visits: 1,489
Can you show the output from sys.dm_db_index_physical_stats for the index? I suspect you may be looking at intermediate levels and not the leaf level.



My blog: SQL Soldier
Twitter: @SQLSoldier
My book: Pro SQL Server 2008 Mirroring
Microsoft Certified Master: SQL Server 2008
Principal DBA: Outerwall, Inc.
Also available for consulting: SQL DBA Master
Post #1410196
Posted Tuesday, January 22, 2013 11:51 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, April 14, 2014 12:29 PM
Points: 81, Visits: 289
DECLARE @db_id SMALLINT;
DECLARE @object_id INT;
SET @db_id = DB_ID(N'dbName');
SET @object_id = OBJECT_ID(N'tableName');
IF @object_id IS NULL
BEGIN;
PRINT N'Invalid object';
END;
ELSE
BEGIN;
SELECT * FROM sys.dm_db_index_physical_stats(@db_id, @object_id, 11, NULL , 'LIMITED');
END;
GO

database_id object_id index_id partition_number index_type_desc alloc_unit_type_desc index_depth index_level avg_fragmentation_in_percent fragment_count avg_fragment_size_in_pages page_count avg_page_space_used_in_percent
5 1963870063 11 1 NONCLUSTERED INDEX IN_ROW_DATA 4 0 94.0136877112937 206272 1.05830165994415 218298 NULL

edit: heres a link ot the screenshot, thats impossible to read
http://bit.ly/WdEMNW

thanks! :)
Post #1410203
Posted Tuesday, January 22, 2013 12:15 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, April 14, 2014 12:29 PM
Points: 81, Visits: 289
for giggles, I rebuilt with a 50% fill factor:

avg_fragmentation_in_percent changed to 94.691...
Fragment_count up to 380190
avg_fragment_size_in_pages a touch over 1.03
and page_count is up (as expected) to 394577

Post #1410210
Posted Tuesday, January 22, 2013 12:21 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 7:05 AM
Points: 41,532, Visits: 34,449
You have autoshrink on by any chance?

btw, you can attach images to the posts. I'm not clicking on an obfuscated link that could go anywhere.



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 #1410214
Posted Tuesday, January 22, 2013 12:24 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, April 14, 2014 12:29 PM
Points: 81, Visits: 289
its a link to my dropbox, but understand your hesitation. dont have another place handy to stick that image at the moment, so sorry...

I DO NOT have auto-shrink enabled. (just double checked to be positive, whew!)
Post #1410216
Posted Tuesday, January 22, 2013 12:25 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Yesterday @ 1:29 PM
Points: 1,593, Visits: 1,489
You are definitely looking at the right level of the index. There must simply not be enough contiguous free space for it to rebuild it unfragmented.



My blog: SQL Soldier
Twitter: @SQLSoldier
My book: Pro SQL Server 2008 Mirroring
Microsoft Certified Master: SQL Server 2008
Principal DBA: Outerwall, Inc.
Also available for consulting: SQL DBA Master
Post #1410217
Posted Tuesday, January 22, 2013 12:27 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 7:05 AM
Points: 41,532, Visits: 34,449
LAW1143 (1/22/2013)
its a link to my dropbox, but understand your hesitation. dont have another place handy to stick that image at the moment, so sorry...


btw, you can attach images to the posts.



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 #1410219
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse