You cannot totally turn off logging and in most cases you don't want to turn off logging. There is no rollback and no transaction recovery without logging. Even if a database is set in Simple recovery Mode (SQL 2000) or the Trunc. Log on Checkpoint Option is On (SQL 7 and earlier) SQL must still log transactions in order to enable rollback.
In (<List>) is slow. Try either of these alternatives for faster performance - Where Exists Or Inner Join.
--Example: Where Exists
--Use explicit transactions
Begin Transaction
--Lock the table at the start of the mass delete
--This increases performance because SQL must
--only obtain one lock rather than multiple
--page locks
Delete tablename With (tablockx holdlock)
From tablename t
Where Exists
(Select * From AnotherTable Where value=t.value)
--Example: INNER JOIN
Begin Transaction
Delete tablename With (tablockx holdlock)
From tablename t
Join AnotherTable a
On t.value=a.value
Commit
As Scotty_Roo mentioned, logging affects performance. The primary reason for this is the physical IO required. When a large number of updates are done on a database, SQL Server may need to grow the log file. Growing a log file to handle mass updates can cause several problems - slow performance and running out of disk space are the two most frequent problems encountered.
SQL performs smaller sized batches more efficiently that large batches. Rather than updating 10M rows in one SQL statement, SQL will run 10 batches of 1M much faster. 100 batches of 100K rows will usually perform even better.
Here is is an example script that shows how to perform multiple small batches of updates.
--Use SET ROWCOUNT to limit the number of
--rows updated by a SQL statement
Set rowcount 100000
Declare @rc int
Set @rc=1
While @rc>0
Begin
Begin Transaction
Delete tablename With (tablockx holdlock)
From tablename t
Where Exists
(Select * From AnotherTable
Where value=t.value)
--Get number of rows deleted
Set @rc=@@rowcount
Commit
End
--Reset rowcount to 0 which means unlimited
Set rowcount 0
Let me know if you have any questions about these comments or examples.
Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.