1

I would like to know if there is way that I can run multiple SELECT queries or stored procedures in parallel? For a long time I was using one stored procedure which looks like below:

SELECT 1.......

SELECT 2 .......

SELECT 3 .......

Then I got DataSet with multiple DataTables.

Now I would like to run each SELECT statements parallel. I am not sure if I can do this using the same SqlConnection or if I have to use a separate connection for each query?

Do I have to use threads?

4
  • Does each select statement return the same columns or different columns? Commented Oct 17, 2014 at 8:37
  • Different. This SELECT statements can be stored procedures too. Commented Oct 17, 2014 at 8:48
  • @kumarch How this affect performance? What will be the best way to query multiple tables/view eg. for drop down lists in page? Will creating multiple connections improve the performance? Commented Oct 17, 2014 at 10:50
  • What about Thread Pool ? Commented Oct 18, 2014 at 11:51

1 Answer 1

1

SQL Server will run all the 3 SELECTs in same session and in sequence as per you've done above.

If you want to execute all 3 SELECTs in parallel then you will have to invoke 3 threads (3 SPIDs, by creating separate connections) and execute by any script, like C# or VBA. But still its not guaranteed if they will run exactly parallel.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.