Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Feb 22 '12 at 14:31

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

1  
no real answer possible, read up about connection pooling and locking mechanisme –  Schwarzie2478 Feb 21 '12 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 '12 at 10:06

6 Answers 6

up vote 6 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"

share|improve this answer

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

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

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

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.