Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Native TSQL support for parallel queries

Is there native support for executing queries in parallel from a stored procedure in SQL Server 2008 R2? Take this pseudo code for example

create proc dbo.MySproc
as
   delete from SomeTable where Predicate = true [as parallel]
   delete from AnotherTable where Predicate = false [as parallel]

   [wait for queries]

   select * from SomeTable join AnotherTable on Predicate = true

I've seen examples of doing this but they require installing non native CLR procedures which is what I want to avoid.

NOTE: I'm not talking about execution plans, I mean running two non related queries at the same time async, not one after the other.

like image 492
Dustin Davis Avatar asked Nov 18 '11 20:11

Dustin Davis


Video Answer


2 Answers

No, there is no T-SQL syntax for controlling parallelism.

There are a number of games you can play to get something similar but they all require a non T-SQL entity. For example, SQL Server Jobs, CLR SPs that spawn multiple threads, C# app that spawns the threads, use of sqlcmd to execute T-SQL etc.

like image 59
Russell McClure Avatar answered Nov 15 '22 04:11

Russell McClure


How can I run sql server stored procedures in parallel? - it's about stored procedures, but maybe you'll find something useful.

like image 45
Michał Powaga Avatar answered Nov 15 '22 05:11

Michał Powaga