Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 Multithreading in MS SQL

Author  Topic 

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-10-05 : 03:57:07
Hello,
we have an application that deals with millions of numbers and we just revamped the whole system and moved to 2008.

Our application is optimized to process millions of numbers broken down to batches of 1,000 each. These batches are processed one by one. Optimized for speed to the remote server

MY Question is thus:

Whats the best way to run batches in multiple threads ie. If a SP starts a process such as


declare @batch varchar(max), @results varchar(max), @counter int, @total int

set @total = select max(number) from gateway where username = @user


set @counter = 0

while @counter =< @total
begin

set @batch = -- selects the top 1,000, next 2,000 etc up to 100,000 or millions or records

set @results = (select [dbo].[function_to_process_execution](@batch))
set @counter = @counter + 1
end




[dbo].[function_to_process_execution] is a function to process the csv sent to it and return a status code to the calling SP.

The calling SP has to wait for the above code to finish execution.

When we have large batches in the millions to process, whats the easiest way to execute the batches without having to loop 1,000 + times.

Can this be assigned to multiple threads of execution, further breaking down the batches ?

Or am I doing this wrong ? Please advice

thanks

Ehi





spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-10-05 : 07:18:07
if you call every sproc from it's own connection you have multithreading.

other way is to have a service broker activation sproc that you can specify how many of them you want to run in parallel.

_______________________________________________
Causing trouble since 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.0 out!
Go to Top of Page
   

- Advertisement -