简体   繁体   中英

Performance of Delete then Insert vs Merge in SQL Server

I have a SQL Server 2008 query which looks like this

Delete from Table1

INSERT INTO TABLE1
SELECT * FROM Table2

And I would like to improve the performance of this query by some means.

So, would be a nice approach to replace the Delete and Insert query with Merge statement which handles Delete, Update and Insert in one single batch.

Please advice if any other way exist through which i can improve the performance of query.

When you compare query profile statistic of using merge command and using insert and deleted command pay attention that merge command have better performance because number of insert, update,delete and select statement also number of transaction is lower in merge command. Also amount of DTS package is lower in merge command.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM