sql - Why does speed increases when updating datetime column with index -


i have sql server 2014 ctp2 database table datetime column called expirationdate has non-unique, non-clustered index.

the index creation statement is:

create index ix_expirationdate on my_table (expirationdate); 

my c# application (self-hosted wcf service) uses ado.net select & update queries my_table table.

i created test application performs following scenario:

  1. select 1 item database

    select top (1) id, expirationdate, ... my_table (nolock) status = 1 , ... order my_table.expirationdate asc

  2. change item in test application

    item.status = 2;
    item.expirationdate = datetime.now.addhours(2);

  3. update item in database

    update my_table set expirationdate = @expirationdate, status = 2, ... (my_table.id = @id);

i have 2 cases in application:

  1. change expirationdate in test application before database update
  2. not change expirationdate in test application before database update

i run test application 10000 items in database , results show first case 4x faster second.

can please explain why there such huge performance gain if datetime column index updated?


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -