We’re developing a product that relies on the Microsoft Sync Framework to keep the data on a client app and on the server in sync. What we have noticed is when syncing about 16 tables and ~2200 records it will take about 4 minutes, which is not acceptable.
Using the SQL Server Profiler we found it is using sp_executesql to execute the queries. when run without sp_executesql a specific query runs in <1s, but with it takes over 10s.
So the question is: What are we doing wrong and is there anything we can do to speed it up.
sp_executesql is using dynamic sql. each row is being processed singularly.
4 minutes seems rather long, you should look at the design of your 16 tables and check the performance on them. Try using the execution plan to view where the bottleneck may be occurring.
check out this link that covers the basics:
SQL Execution Plan basics
Try scrolling down to the bottom of the article, where there are screen shots of the actual graphical interface in SQL Management Studio. There are some boring parts of the article, but you can atleast see the graphical execution plan and its benefits.