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?
|
migrated from stackoverflow.com Feb 22 '12 at 14:31
|
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" |
|||
|
|
|
As long as your first query doesn't lock a table needed in your second query, they will run in parallel. |
|||
|
|
|
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. |
|||
|
|
|
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. |
|||
|
|
|
DDL (data definition language) work parallel like SELECT statement |
|||
|
|
|
If you are writing the queries like below...it will run parallelly
Note - Your parallel query will come in waiting state in case any bulk insert in a table |
|||
|
|
