문제

I have an application I’m writing in access with a SQL server backend. One of the most heavily used parts is where the users selects an answer to a question, a stored procedure is then fired which sees if an answer has already been given, if it has an UPDATE is executed, if not an INSERT is executed.

This works just fine but now we have upgraded to SQL server 2008 express I was wondering if it would be better/quicker/more efficient to rewrite this SP to use the new MERGE command.

Does anyone have any idea if this is faster than doing a SELECT followed by either an INSERT or UPDATE?

도움이 되었습니까?

해결책

Not worth the effort. Possibly doable, but it will not give you anything noticable.

MERGE is especially targeting data warehouses where finding out what to insert/update is the tricky part. It allows all operations (insert, update) to be done with ONE set of merges, compared to one for each condition. This makes no real difference in your case.

I have one database where I am uploading 3-5 million rows into a 300 million row table - there merge improoves my performance by 50% (one table scan instead of two).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top