Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

efficient way to do multi threaded calls to sql server?

i have an sql stored procedure that will call to TOP 1000 records from a table that function like a queue-in this table there will be more or less 30,000-40,000 records.the call to the SP takes ~4 seconds (there's an xml column) so to finish the calls it will take ~2 minutes. i thought to use multi threaded calls and to insert the records to a sync dictionary\list. did someone did that before? any efficient way to end the calls as soon as possible? Thanks...

like image 957
user437631 Avatar asked Jun 26 '26 07:06

user437631


1 Answers

Consider optimizing the query before resorting to threads.

In my experience, when beginners at multi-threading implement threads, it usually does not improve performance. Worse, it usually introduces subtle errors which can be difficult to debug.

Optimize the query first, and you may find that you don't need threads.

Even if you implemented them, eventually you'll have SQL Server doing too much work, and the threaded requests will simply have to wait.

like image 192
John Saunders Avatar answered Jun 28 '26 22:06

John Saunders