Unordered results in SQL

Some SQL Server examples where the exact same execution plan can return differently ordered results are

  1. An unordered index scan might be carried out in either allocation order or key order dependant on the isolation level in effect.
  2. The merry go round scanning feature allows scans to be shared between concurrent queries.
  3. Parallel plans are often non deterministic and order of results might depend on the degree of parallelism selected at runtime and concurrent workload on the server.
  4. If the plan has nested loops with unordered prefetch this allows the inner side of the join to proceed using data from whichever I/Os happened to complete first

Leave a Comment