Paul White explains how to perform minimal logging when using the INSERT..SELECT
pattern to insert into an empty table with a clustered index:
The summary top row suggests that all inserts to an empty clustered index will be minimally logged as long as
TABLOCK
andORDER
hints are specified. TheTABLOCK
hint is required to enable theRowSetBulk
facility as used for heap table bulk loads. AnORDER
hint is required to ensure rows arrive at the Clustered Index Insert plan operator in target index key order. Without this guarantee, SQL Server might add index rows that are not sorted correctly, which would not be good.Unlike other bulk loading methods, it is not possible to specify the required
ORDER
hint on anINSERT...SELECT
statement. This hint is not the same as using anORDER BY
clause on theINSERT...SELECT
statement. AnORDER BY
clause on anINSERT
only guarantees the way any identity values are assigned, not row insert order.
Read on to see what you can do.