Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 223083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:11:16+00:00 2026-05-11T19:11:16+00:00

What is Index Maintenance and how do I do it? How frequently do I

  • 0

What is Index Maintenance and how do I do it? How frequently do I have to do it?
What are the benefits?
This is related to a transaction table which is subject to frequently modifications; all DML operations will be run on that table.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:11:16+00:00Added an answer on May 11, 2026 at 7:11 pm

    I second everything that Jonathan said – except for the frequency of index maintenance.

    Well, if you happen to have a poorly designed index (such as a clustered index on a GUID key), you might actually need to do it at least every night – or even during the day, too.

    As a general rule of thumb: if your index fragmentation is below 5%, all is fine. If you have fragmentation between 5% and approx. 30%, you should do an index reorganization:

    ALTER INDEX (your index name) ON (your table name) REORGANIZE
    

    If your index has index fragmentation of more than 30%, you need to rebuild it completely:

    ALTER INDEX (your index name) ON (your table name) REBUILD
    

    Rebuilding an index can be disruptive – try to do it at off-hours, e.g. during the night.

    In order to determine index fragmentation, you can use this DMV query:

    SELECT 
        t.NAME 'Table name',
        i.NAME 'Index name',
        ips.index_type_desc,
        ips.alloc_unit_type_desc,
        ips.index_depth,
        ips.index_level,
        ips.avg_fragmentation_in_percent,
        ips.fragment_count,
        ips.avg_fragment_size_in_pages,
        ips.page_count,
        ips.avg_page_space_used_in_percent,
        ips.record_count,
        ips.ghost_record_count,
        ips.Version_ghost_record_count,
        ips.min_record_size_in_bytes,
        ips.max_record_size_in_bytes,
        ips.avg_record_size_in_bytes,
        ips.forwarded_record_count
    FROM 
        sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, 'DETAILED') ips
    INNER JOIN  
        sys.tables t ON ips.OBJECT_ID = t.Object_ID
    INNER JOIN  
        sys.indexes i ON ips.index_id = i.index_id AND ips.OBJECT_ID = i.object_id
    WHERE
        AVG_FRAGMENTATION_IN_PERCENT > 0.0
    ORDER BY
        AVG_FRAGMENTATION_IN_PERCENT, fragment_count
    

    Michelle Ufford has a great automatic index defrag script – highly recommended! Or then you should look into setting up SQL Server maintenance plans which can run e.g. every night and clean up your indices.

    Marc

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 159k
  • Answers 159k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer App Engine does not strip out the Host header: it… May 12, 2026 at 11:31 am
  • Editorial Team
    Editorial Team added an answer There is apparently a lot of misunderstanding about this! The… May 12, 2026 at 11:31 am
  • Editorial Team
    Editorial Team added an answer This avoids the slow "//" operator. count(/Shops/Shop/Product[type = 'Milk']) May 12, 2026 at 11:31 am

Related Questions

I need to setup a maintenance page for a website I'm running, e.g. for
I've now completed my first web application using ASP.NET MVC and overall, I still
I have a log that is really huge. (millions of rows) LogTable ------- ID
This question is not so much programming related as it is deployment related. I

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.