Does SQL Server execute queries in parallel? In other words, if I run a heavy query that takes 10 seconds to execute, and at the same time start another heavy query that takes 10 seconds, will the second query actually start after 10 seconds, or will they start both at the same time?

link|improve this question
1  
no real answer possible, read up about connection pooling and locking mechanisme – Schwarzie2478 Feb 21 at 10:01
1  
More relevant to read up on SQL Server workers and the co-operative scheduling mechanism IMO. In general the answer to your question is "yes". – Martin Smith Feb 21 at 10:06
feedback

migrated from stackoverflow.com Feb 22 at 14:31

This question came from our site for professional and enthusiast programmers.

6 Answers

up vote 5 down vote accepted

You mean "concurrently". The answer is yes, with caveats that are too broad to discuss here. The whole point of RDBMS is concurrency...

"Parallel" has a precise meaning in SQL Server: "a single query is distributed over more then one processor core"

link|improve this answer
feedback

As long as your first query doesn't lock a table needed in your second query, they will run in parallel.

link|improve this answer
feedback

Depends on data - usually they run parallel, but some locking scenarios may cause one query wait for another. Of course if disk subsystem is weak and you have not plenty of RAM, multiple queries may run slower.

link|improve this answer
feedback

The queries run in parallel, as far as possible.

The database uses different locks for read and write, on rows, blocks or whole tables, depending on what you do.

If one query only reads from a table, another query can also read from the same table at the same time. If one query updates some records in a table, another query may still be able to read from the table as long as it doesn't read any records that were locked for the update.

link|improve this answer
feedback

DDL (data definition language) work parallel like SELECT statement
DML (Data modified language) does not work parallel like INSERT and UPDATE statement

link|improve this answer
feedback

If you are writing the queries like below...it will run parallelly

SET XACT_ABORT ON
Begin Try
     Begin Tran
        --Your Sql Statement
     Commit Tran
End Try
Begin Catch
    Rollback Tran
End Catch

Note - Your parallel query will come in waiting state in case any bulk insert in a table

link|improve this answer
feedback

Your Answer

 
or
required, but never shown