Solved

SQL database index fragmentation percentage

Posted on 2014-02-12
1
719 Views
Last Modified: 2014-02-12
I am not familiar with database index fragmentation. I spoke to my friend regarding my database poor performance,  he advised me to do the re-index. Based on his input I have executed the following SQL query and it is shows all the  table   having  indexstats.avg_fragmentation_in_percent > 30



SELECT OBJECT_NAME(ind.OBJECT_ID) AS TableName,
ind.name AS IndexName, indexstats.index_type_desc AS IndexType,
indexstats.avg_fragmentation_in_percent
FROM sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, NULL) indexstats
INNER JOIN sys.indexes ind  
ON ind.object_id = indexstats.object_id
AND ind.index_id = indexstats.index_id
WHERE indexstats.avg_fragmentation_in_percent > 30
ORDER BY indexstats.avg_fragmentation_in_percent DESC


I have given sample output
Output:
Table name  index Name          Index Type                avg_fragmentation_in_percent
Employee     NULL                              Heap                     98.75
Sales            PK_SALES          CLUSTERED INDEX              85
Customer   NULL                          Heap                             45
Vendor         PK_VEN           CLUSTERED INDEX                60


Should I have to re-index all the above tables ?  
Employee &      Customer    does not have index . Should I have to create a index for that table ?
Does Re-build required or not ?
Should I have to monitor the  avg_fragmentation every day ?
Is there is any tool available in the market to monitor and performance this operation ?
0
Comment
Question by:Varshini S
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
ID: 39854287
You can rebuild all the indexes with fragmentation > 30 and re frag the others
Use the maintenance plans mentioned here

http://ola.hallengren.com/ 

>Should I have to monitor the  avg_fragmentation every day ?
It depends on the no of inserts and updates on those tables, usually I perform this once a week
>Is there is any tool available in the market to monitor and performance this operation ?
use the query mentioned in the above link, that takes care of which to reindex
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have a large data set and a SSIS package. How can I load this file in multi threading?
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question