Featured post
entity framework 4 - Microsoft SQL Server 2008 - 99% fragmentation on non-clustered, non-unique index -
i have table several indexes (defined below). 1 of indexes (ix_external_guid_3) has 99% fragmentation regardless of rebuilding/reorganizing index. have idea might cause this, or best way fix it?
we using entity framework 4.0 query this, ef queries on other indexed fields 10x faster on average external_guid_3 field, ado.net query same speed on both (though 2x slower ef query indexed fields).
table
- id(pk, int, not null)
- guid(uniqueidentifier, null, rowguid)
- external_guid_1(uniqueidentifier, not null)
- external_guid_2(uniqueidentifier, null)
- state(varchar(32), null)
- value(varchar(max), null)
- infoset(xml(.), null) --> 2-4k
- created_time(datetime, null)
- updated_time(datetime, null)
- external_guid_3(uniqueidentifier, not null)
- fk_id(fk, int, null)
- locking_guid(uniqueidentifer, null)
- locked_time(datetime, null)
- external_guid_4(uniqueidentifier, null)
- corrected_time(datetime, null)
- is_add(bit, not null) score(int, null)
- row_version(timestamp, null)
indexes
- pk_table(clustered)
- ix_created_time(non-unique, non-clustered)
- ix_external_guid_1(non-unique, non-clustered)
- ix_guid(non-unique, non-clustered)
- ix_external_guid_3(non-unique, non-clustered)
- ix_state(non-unique, non-clustered)
note: sql server best practices state indexes less 10,000 pages not benefit performance gains.
see http://technet.microsoft.com/en-gb/library/cc966523.aspx http://technet.microsoft.com/en-us/magazine/2008.08.database.aspx?pr=blog
here's little snippet identify when db needs defragging.in our product, reduced 2000 , chose >20% fragmentation. can modify script tell indecies in particular.
select count(*) fragmented_indexes sys.dm_db_index_physical_stats(db_id(), null, null, null, null) p p.avg_fragment_size_in_pages <= 1 , p.avg_fragmentation_in_percent >= 20 , p.page_count > 2000;
- Get link
- X
- Other Apps
Comments
Post a Comment