FIX: SELECT with ORDER BY Does Not Maintain Sort Order if Run in Parallel

This article was previously published under Q276060
This article has been archived. It is offered "as is" and will no longer be updated.
BUG #: 58305 (SQLBUG_70)
SYMPTOMS
A SELECT statement that contains an ORDER BY clause may not return results in the specified sort order if the query is run in parallel on a computer with two or more processors.

You can determine if the query is being run in parallel by viewing the execution plan. To obtain the execution plan, execute SET SHOWPLAN_TEXT ON in a separate batch before the query. For example:
USE pubsGOSET SHOWPLAN_TEXT ONGOSELECT * FROM authorsGO				
A parallel plan contains the word "Parallelism" in the execution plan output; the following example demonstrates this:
|--Parallelism(Repartition Streams, PARTITION COLUMNS:([fvs].[FileID]))                                          |    |    |    |    |         |    |--IndexSeek(OBJECT:([LBDB2].[dbo].[FileVersion].[IX_FileVersion_MSNFV] AS [fvs]),SEEK:([fvs].[MirrorSN] <= [@msn]) ORDERED)                                          |    |    |    |    ||--Parallelism(Repartition Streams, PARTITION COLUMNS:([f].[ID]))                                          |    |    |    |    |              |--Clustered IndexSeek(OBJECT:([LBDB2].[dbo].[File].[PK_File] AS [f]),SEEK:([f].[DriveVSN]=1083842463) ORDERED)                                          |    |    |    ||--Parallelism(Repartition Streams, PARTITION COLUMNS:([fv].[FileID]))				
RESOLUTION
To prevent the specific query from having a parallel plan, specify the MAXDOP option with a value of 1. For example, on the Pubs database:
SELECT * FROM authors OPTION (MAXDOP 1)				
STATUS
Microsoft has confirmed this to be a problem in SQL Server 7.0. This problem has been corrected in U.S. Service Pack 3 for Microsoft SQL Server 7.0. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
274799 INF: How to Obtain Service Pack 3 for Microsoft SQL Server 7.0 and Microsoft Data Engine (MSDE) 1.0
For more information, contact your primary support provider.
MORE INFORMATION
For more information, see the following sections in SQL Server Books Online:
"Parallel Query Example"
"Parallel Query Processing"
"Degree of Parallelism"
Properties

Article ID: 276060 - Last Review: 10/21/2013 02:28:56 - Revision: 2.1

  • Microsoft SQL Server 7.0 Standard Edition
  • kbnosurvey kbarchive kbbug kbfix KB276060
Feedback