SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Performance issue due to index fragmentation.


Performance issue due to index fragmentation.

Author
Message
homebrew01
homebrew01
SSCertifiable
SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)

Group: General Forum Members
Points: 6223 Visits: 9177
striker-baba (4/23/2010)
I tried to query the fragmentation stats on that table.
using

SELECT
a.index_id,
name,
avg_fragmentation_in_percent
FROM sys.dm_db_index_physical_stats (DB_ID(' DB '),OBJECT_ID(' Table'A' '),NULL, NULL, NULL) AS a
JOIN sys.indexes AS b ON
a.object_id = b.object_id AND
a.index_id = b.index_id;

but the query is taking tooo long.....
I checked activity monitor. and it has IX locks on that table and the wait time is 2955150046.

Is there any other place where I can look for some information.


Can you run that during off-hours ?
If you're doing a lot of inserts, maybe you should just rebuild indexes anyway ?



Sanjay Rohra
Sanjay Rohra
SSChasing Mays
SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)

Group: General Forum Members
Points: 649 Visits: 307
Sanjay Rohra (4/23/2010)
If you run all the jobs that are going to insert data into Table A in parallel, there will definitely be blocking and it might also lead to deadlock causing your jobs to be terminated by the SQL engine. If possible, execute those jobs sequentially. Once done, check for fragmentation and do a re-org or rebuild of indexes.


Just to add to my point, since there are multiple inserts daily, your indexes will definitely fragment out. You will have to rebuild them anyway. You can still cross-check the level of fragmentation by querying the sys.dm_db_index_physical_stats DMV, but do that only when there are no Inserts currently happening in your table.
striker-baba
striker-baba
SSC Veteran
SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)

Group: General Forum Members
Points: 221 Visits: 538
Thanks to all for the replies.

I ran the query
SELECT
a.index_id,
name,
avg_fragmentation_in_percent
FROM sys.dm_db_index_physical_stats (DB_ID(' dbname '),OBJECT_ID(' table a '),NULL, NULL, 'limited') AS a
JOIN sys.indexes AS b ON
a.object_id = b.object_id AND
a.index_id = b.index_id;

and I have 5 indexes on my table
and all 3 indexes are 96% fragmented and 2 of them are 66% fragmented.

I am planning to archive the data and rebuild the indexes on that table.

DO you guys think this will work out .... or Any suggestions.
homebrew01
homebrew01
SSCertifiable
SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)

Group: General Forum Members
Points: 6223 Visits: 9177
striker-baba (4/23/2010)
Thanks to all for the replies.

I ran the query
SELECT
a.index_id,
name,
avg_fragmentation_in_percent
FROM sys.dm_db_index_physical_stats (DB_ID(' dbname '),OBJECT_ID(' table a '),NULL, NULL, 'limited') AS a
JOIN sys.indexes AS b ON
a.object_id = b.object_id AND
a.index_id = b.index_id;

and I have 5 indexes on my table
and all 3 indexes are 96% fragmented and 2 of them are 66% fragmented.

I am planning to archive the data and rebuild the indexes on that table.

DO you guys think this will work out
.... or Any suggestions.


That should be an improvement.



Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search