?
Solved

SQL 2000 defrag index's

Posted on 2006-12-01
3
Medium Priority
?
666 Views
Last Modified: 2008-03-06
I have a script to defrag some indexes however after building a list an a temp table it does the following to select which indexes to defrag:

SELECT ObjectName, ObjectId, IndexId, LogicalFrag
   FROM #fraglist
   WHERE LogicalFrag >= 25
     AND INDEXPROPERTY (ObjectId, IndexName, 'IndexDepth') > 0

This only returns one row but on inspection there are loads of indexes with a crap scan density, my question is this:

If i remove :

 AND INDEXPROPERTY (ObjectId, IndexName, 'IndexDepth') > 0

And just defrag all of the indexes with fragmentation > 25 will this cause any problems or will this work with out issue. In summary do I need to do the second check on the index properties and if I remove it am I safe to defrag all the indexes?

Cheers
0
Comment
Question by:Netstore
[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
3 Comments
 
LVL 11

Accepted Solution

by:
lluthien earned 2000 total points
ID: 18053044
if you remove the indexdepth check,
you will _not_ skip the systemtables.

so you'd have to figure out another away around that,

   WHERE LogicalFrag >= 25

are you sure you're checking the right fragmentation percentage?

this link has some background info:
http://www.sql-server-performance.com/tp_automatic_reindexing.asp
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

764 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