Performance tuning an update statement in SQL SERVER -


i have 2 update statements. when executed both taking more 12hrs ssis. indexes on tables disabled before executing update statements. need improve performance. need suggestions:

1) first update statement

update db1.table1 set db1.table1.col1 = db2.table2.col1 db1.table1, db2.table2 db1.table1.col2 = db2.table2.col2 

2) second update statement

update table1 set table1.col3 = 0 table1 table1.col3 null 

can update in batches improving performance of 1st update statement? see having default on col3 sufficient instead of running second update. not sure if effects insert queries. table having lot of data. not sure of altering table include default value on column table having lot of data.

please provide suggestions performance tune above statements. please note not having proper permissions on db verify execution plan.

first, know update taking longer. but, indexes not enemy when doing updates.

the first update:

update t1     set t1.col1 = t2.col2     db1.table1 t1 join          db2.table2 t2          on t1.col2 = t2.col2; 

this update needs index on db2.table2(col2). otherwise, need nested loop join.

the second update:

update table1 set table1.col3 = 0 table1 table1.col3 null 

is bit trickier. updating column in where clause. sense if relatively few of values null -- few percent -- index on table1(col3) help. if many of columns null, index less useful. without index, requires full table scan , should not absurdly slow.

you may find batching updates on table performance.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -