Returning results from parallel queries

Results from parallel queries are returned through one of three merge strategies, or as the final step in a sort. Parallel queries that do not have a final sort step use one of these merge types:

More than one merge type can be used when queries require several steps or multiple worktables.

See “showplan messages for parallel queries” for more information on merge messages.

For parallel queries that include an order by clause, distinct, or union, results are stored in a worktable in tempdb, then sorted. If the sort can benefit from parallel sorting, a parallel sort is used, and results are returned to the client during the final merge step performed by the sort.

For more information on how parallel sorts are performed, see Chapter 26, “Parallel Sorting.”

NoteSince parallel queries use multiple processes to scan data pages, queries that do not use aggregates and do not include a final sort step may return results in different order than serial queries and may return different results for queries with set rowcount in effect and for queries that select into a local variable.

For details and solutions, see “When parallel query results can differ”.