|
I have an update query which is updating 10000+ records. To improve the performance, I want no logs to be created for this update statement. How can I set the transaction log off for this update query. Scheduler regularly runs this query to update data. Regards, Satish
(comments are locked)
|
|
Up to my knowledge you cannot turn off transaction log for update. If update query affects different columns of each row, if transaction log is not there it won't rollback, if it couldn't be trusted to complete an atomic fashion or even at all if it were not being logged.
(comments are locked)
|
|
There is no way to turn off logging. 10,000+ rows doesn't sound like much. If performance is not what you want then take a look at the execution plan to see if creating some indexes could improve things.
(comments are locked)
|
|
I think you may have other things to worry about than the transaction log. Large updates (or many small ones) may cause index fragmentation and statistics that are out of date. This will affect performance in the end. You need to check for index fragmentation on regular basis. And you cannot rely on auto update statistics, because auto update will be triggered after 20% of the rows have been updated / inserted (a little simplified). Inccorect statistics may cause an ineffective execution plan. I know, this was not the answer you were looking for, but you cannot turn of logging on updates. You can avoid logging in BULK INSERTS, but not updates or deletes.
(comments are locked)
|
|
I had a similar problem where I was updating or deleting millions of records. This would cause problems with log files as well as server performance problems when it was running the update/delete statements. As mentione above, updating fewer records is what I would recommend. I got round the problem by getting the sql code to delete (or update) the records in batches of 5000 records. A loop was used to delete sets of 5000 records until there were no more to delete/update. This made a big difference with the log file and server performace. I used this approach when I was having to delete in excess 60 million records in one delete statement. This was much quicker and there was not a performance issue. An example of the delete script I used is as follows (this could easily be modified to update as well as delete). So, if I had a millian records to delete, it would still acheive this automatically by deleteing in batches of 5000 records:
Also notice that the above script has a break out so that if it attempts to delete more that 250 baches of 5000 records it stops. Good answer, it will help all the people that will do large update/deletes (10 000 records doesn't qualify as a large update :) but on the other hand the qeustion was about more than 10 000 ). One thing to remember anyway is the index fragmentation. If the columns in the where clause are indexed (I hope they are), it will be fragmented and the last deletes will take longer time to execute. But on the other hand, it may be the only way to delete millions of rows.
Nov 04 '09 at 05:51 AM
Håkan Winther
(comments are locked)
|
|
Question to Stuart Grace. If I use the following below to update a few million over 200 million records I have to worry about batches?
set
(comments are locked)
|
1 2 next page »

