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 8987515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:48:49+00:00 2026-06-15T21:48:49+00:00

We currently have a SQL Agent Job that runs once a week to identify

  • 0

We currently have a SQL Agent Job that runs once a week to identify highly fragment indexes and rebuild them. For certain large indexes on large tables, this ends up causing the system to timeout, as the index is unavailable during the rebuild.

We have identified a strategy that should significantly reduce the fragmentation that occurs, but that won’t be implemented for some time, and it doesn’t cover everything.

We checked in to upgrading to the Enterprise edition, which allows for online index rebuilding. However, the cost is prohibitive for us at this point.

The indexes don’t really change that much, so we can assume that they are static, at least for the most part.

I did envision a way that we could perhaps simulate the online index rebuilding. It could work as follows

For each of the large indexes identified, run a script to:

  • Check the fragmentation and proceed if it exceeds a certain threshold.
  • Create a new index, entitled CurrentIndex_TEMP.
  • Initiate a rebuild on the index.
  • Remove the temporary index.

It seems that once the temporary index has been built, it would be possible to rebuild the other index without causing any downtime, since SQL Server would have another index that would then be available to use on queries that would have otherwise used the other query.

Iterating through this for each index would hopefully minimize the increase in overall index size, as each temporary index would be removed before any other temporary indexes were created.

This strategy would also retain the historical data on the indexes. I had originally considered a strategy of first renaming the current index, then creating it again with the original name, and then removing the index that had been renamed. This, however, would result in a loss of history.

So, my question…

Is this a feasible strategy? Are there any significant problems I may run into? I understand that this will take some manual oversight from time to time, but I’m willing to accept that at this point.

Thanks for the help.

  • 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-06-15T21:48:50+00:00Added an answer on June 15, 2026 at 9:48 pm

    Any offline index rebuild with lock the table so you don’t gain anything by creating a duplicated index.

    With great effort your can simulate online index rebuilds. You have to rebuild all indexes on the table at once.

    1. Create a copy of the table T with identical schema (“T_new“)
    2. Rename T to T_old
    3. Create a view T defined as select * from T_old and set up INSTEAD OF DML triggers which perform all DML on both T_old and T_new
    4. In a background job copy over batches from T_old to T_new using the MERGE statement
    5. Finally, after the copy is completed, perform some renaming and dropping to make T_new the new T

    This requires insanely high effort and good testing. But you can realize pretty much arbitrary schema changes with this online.

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

Sidebar

Related Questions

I have a SQL 2005 instance that runs a job that uses a Powershell
I currently have this sql statement that I wrote and it works but it's
I currently have a SQL query that returns a number of fields. I need
I currently have the following SQL query that lists all the names of all
I have an sql statement that currently is just returning all the end parent
Currently I have a powershell proccess that is scanning a SQL Server Table and
Currently I have a SQL server column of type nvarchar(max) which has text that
The way my team currently schedules jobs is through the SQL Server Job Agent.
I currently have a sql statement that outputs data into an excel document. However,
Currently we have a lot of web pages that either have SQL statements embedded

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.