Reputation: 25058
Can something like #pragma_omp (OpenMP) in C for loops
#pragma omp parallel for
for (ii = 0; ii < nrows; ii++){
for(jj = 0; jj < ncols; jj++){
for (kk = 0; kk < nrows; kk++){
array[ii][jj] = array[ii]kk] * array[kk][jj];
}
}
}
be applied to a loop in SQL Server?
WHILE (...) BEGIN
END
Something to paralelize the loop, using threads, How??
Upvotes: 0
Views: 342
Reputation: 107766
In a store procedure I am inserting lots of registries, so I would like to paralelize this, something to control max workers..
What you should do instead is to reformat the work as a SET based task, such as using UPDATE/INSERT into a temp table with the calculations/manipulations encapsulated on a pre-row basis. SQL Server can then parallelize the query as it sees fit.
To control the max workers, have a look at OPTION MAXDOP
Upvotes: 1
Reputation: 135111
In SQL Server you should use a SET based solution not loops, SQL is a SET based based language. You could use Parallel LINQ (PLINQ) to parallel some of the stuff if running from outside SQL Server
Upvotes: 3