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


Rebuilding / Reorganizing indexes not working properly on sql server 2005


Rebuilding / Reorganizing indexes not working properly on sql server 2005

Author
Message
neellotus07
neellotus07
SSC Veteran
SSC Veteran (251 reputation)SSC Veteran (251 reputation)SSC Veteran (251 reputation)SSC Veteran (251 reputation)SSC Veteran (251 reputation)SSC Veteran (251 reputation)SSC Veteran (251 reputation)SSC Veteran (251 reputation)

Group: General Forum Members
Points: 251 Visits: 206
Hi all,

I run following script:-
DECLARE @db_id SMALLINT;
DECLARE @object_id INT;
SET @db_id = DB_ID(N'SFNData');
SET @object_id = OBJECT_ID(N'FDIP_B');
IF @object_id IS NULL BEGIN PRINT N'Invalid object'; END ELSE BEGIN
SELECT IPS.Index_type_desc, IPS.avg_fragmentation_in_percent, IPS.avg_fragment_size_in_pages, IPS.avg_page_space_used_in_percent, IPS.record_count, IPS.ghost_record_count, IPS.fragment_count, IPS.avg_fragment_size_in_pages
FROM sys.dm_db_index_physical_stats(@db_id, @object_id, NULL, NULL , 'DETAILED') AS IPS WHERE IPS.avg_fragmentation_in_percent>0;
END

To find Fragmentation level on table named "ABC" and found avg frag. in percentage as per attached image.

Then i applied rebuild / Reorganize indexes on this table through right click on indexes in S.S.M.S. After rebuilding / Reorganizing i run same script to check frag. level then result showing 0 for Nonclustered Indexed but heap index frag. percentage not updating.

And other problem is when i run this script on same table after 24 hours it showing same avg_frag. percentage for all indexes as it was showing before Rebuilding / Reorganizing indexes.

Please tell me where i am doing wrong. And help me to reduce fragmentation percentage of indexes for fast result from queries.

Thanx in advance

Neel
Attachments
Freg.JPG (12 views, 36.00 KB)
Jeffrey Williams 3188
Jeffrey Williams 3188
SSCoach
SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)

Group: General Forum Members
Points: 17921 Visits: 10039
HEAP's cannot be rebuilt - they will always show fragmentation.

As for the other indexes, how many pages in the index? What are the data types for the indexes? What is the fill factor defined as? And finally, what kind of activity is performed on that table?

Jeffrey Williams
Problems are opportunities brilliantly disguised as insurmountable obstacles.

How to post questions to get better answers faster
Managing Transaction Logs

Grant Fritchey
Grant Fritchey
SSC Guru
SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)

Group: General Forum Members
Points: 93319 Visits: 33003
If the indexes are less than a 8 pages in size, they won't take a full extent and you'll never get complete defragmentation. You may be seeing fragmentation going up overnight because of activity on the system. On most systems, fragmentation is not that big a deal, but you're right to monitor and try to maintain it.

----------------------------------------------------
The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
Theodore Roosevelt

The Scary DBA
Author of: SQL Server Query Performance Tuning and SQL Server Execution Plans
Product Evangelist for Red Gate Software
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