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

  • Home
  • SEARCH
  • 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 1078157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:40:55+00:00 2026-05-16T21:40:55+00:00

For arguments sake, lets say it’s for SQL 2005/8. I understand that when you

  • 0

For arguments sake, lets say it’s for SQL 2005/8. I understand that when you place indexes on a table to tune SELECT statements, these indexes need maintaining during INSERT / UPDATE / DELETE actions.

My main question is this:

When will SQL Server maintain a table’s indexes?

I have many subsequent questions:

I naively assume that it will do so after a command has executed. Say you are inserting 20 rows, it will maintain the index after 20 rows have been inserted and committed.

  • What happens in the situation where a
    script features multiple statements
    against a table, but are otherwise
    distinct statements?

  • Does the server have the intelligence
    to maintain the index after all
    statements are executed or does it do
    it per statement?

I’ve seen situations where indexes are dropped and recreated after large / many INSERT / UPDATE actions.

  • This presumably incurs rebuilding the
    entire table’s indexes even if you
    only change a handful of rows?

  • Would there be a performance benefit
    in attempting to collate INSERT and
    UPDATE actions into a larger batch,
    say by collecting rows to insert in a
    temporary table, as opposed to doing
    many smaller inserts?

  • How would collating the rows above stack up against dropping an index versus taking the maintenance hit?

Sorry for the proliferation of questions – it’s something I’ve always known to be mindful of, but when trying to tune a script to get a balance, I find I don’t actually know when index maintenance occurs.

Edit: I understand that performance questions largely depend on the amount of data during the insert/update and the number of indexes. Again for arguments sake, I’d have two situations:

  • An index heavy table tuned for
    selects.
  • An index light table (PK).

Both situations would have a large insert/update batch, say, 10k+ rows.

Edit 2: I’m aware of being able to profile a given script on a data set. However, profiling doesn’t tell me why a given approach is faster than another. I am more interested in the theory behind the indexes and where performance issues stem, not a definitive “this is faster than that” answer.

Thanks.

  • 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-16T21:40:56+00:00Added an answer on May 16, 2026 at 9:40 pm

    When your statement (not even transaction) is completed, all your indexes are up-to-date. When you commit, all the changes become permanent, and all locks are released. Doing otherwise would not be “intelligence”, it would violate the integrity and possibly cause errors.

    Edit: by “integrity” I mean this: once committed, the data should be immediately available to anyone. If the indexes are not up-to-date at that moment, someone may get incorrect results.

    As you are increasing batch size, your performance originally improves, then it will slow down. You need to run your own benchmarks and find out your optimal batch size. Similarly, you need to benchmark to determine whether it is faster to drop/recreate indexes or not.

    Edit: if you insert/update/delete batches of rows in one statement, your indexes are modified once per statement. The following script demonstrates that:

    CREATE TABLE dbo.Num(n INT NOT NULL PRIMARY KEY);
    GO
    INSERT INTO dbo.Num(n)
    SELECT 0
    UNION ALL
    SELECT 1;
    GO
    -- 0 updates to 1, 1 updates to 0
    UPDATE dbo.Num SET n = 1-n;
    GO
    -- doing it row by row would fail no matter how you do it
    UPDATE dbo.Num SET n = 1-n WHERE n=0;
    UPDATE dbo.Num SET n = 1-n WHERE n=1;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a table with around 20 million rows. For arguments sake, lets say
So I have a unixtime datetime stamp. For arguments sake, lets say it's now
Lets say for the sake of argument that we don't care much about history.
SQL Server 2008 Database Question. I have 2 tables, for arguments sake called Customers
One of the arguments I've heard about blueprint css is that it lets you
I have a silverlight control, for arguments sake let's say it inherits from the
Can my asp.net web application run without a web.config? For argument's sake lets say
Let's just say for argument's sake that you wanted to create a PowerShell Cmdlet
Let's say I have a dropdown that gets its value from a DB table.
I have two folders, for arguments sake /Volumes/A and /Volumes/B. They are mounted network

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.