TechNet
Export (0) Print
Expand All

Exchange Spill Event Class

 

Applies To: SQL Server 2016

The Exchange Spill event class indicates that communication buffers in a parallel query plan have been temporarily written to the tempdb database. This occurs rarely and only when a query plan has multiple range scans.

Normally, the Transact-SQL query that generates such range scans has many BETWEEN operators, each of which selects a range of rows from a table or an index. Alternatively, you can obtain multiple ranges using expressions such as (T.a > 10 AND T.a < 20) OR (T.a > 100 AND T.a < 120). Additionally, the query plans must require that these ranges be scanned in order either because there is an ORDER BY clause on T.a, or because an iterator within the plan requires that it consume the tuples in sorted order.

When a query plan for such a query has multiple Parallelism operators, the memory communication buffers used by the Parallelism operators become full, and a situation can arise whereby the query's execution progress stops. In this situation, one of the Parallelism operators writes its output buffer to tempdb (an operation called an exchange spill) so that it can consume rows from some of its input buffers. Eventually, the spilled rows are returned to the consumer when the consumer is ready to consume them.

Very rarely, multiple exchange spills can occur within the same execution plan, causing the query to execute slowly. If you notice more than five spills within the same query plan's execution, contact your support professional.

Exchange spills are sometimes transient and may disappear as data distribution changes.

There are several ways to avoid exchange spill events:

  • Omit the ORDER BY clause if you do not need the result set to be ordered.

  • If ORDER BY is required, eliminate the column that participates in the multiple range scans (T.a in the example above) from the ORDER BY clause.

  • Using an index hint, force the optimizer to use a different access path on the table in question.

  • Rewrite the query to produce a different query execution plan.

  • Force serial execution of the query by adding the MAXDOP = 1 option to the end of the query or index operation. For more information, see Configure the max degree of parallelism Server Configuration Option and Configure Parallel Index Operations.

System_CAPS_ICON_important.jpg Important


To determine where the Exchange Spill event is occurring when the query optimizer generates an execution plan, you should also collect a Showplan event class in the trace. You can choose any of the Showplan event classes except the Showplan Text and Showplan Text (Unencoded) event classes, which do not return a Node ID. Node IDs in Showplans identify each operation the query optimizer performs when it generates a query execution plan. These operations are called operators and each operator in a Showplan has a Node ID. The ObjectID column for Exchange Spill events corresponds to the Node ID in Showplans so you can determine which operator, or operation, is causing the error.

Data column nameData typeDescriptionColumn IDFilterable
ApplicationNamenvarcharName of the client application that created the connection to an instance of SQL Server. This column is populated with the values passed by the application rather than the displayed name of the program.10Yes
ClientProcessIDintID assigned by the host computer to the process where the client application is running. This data column is populated if the client provides the client process ID.9Yes
DatabaseIDintID of the database specified by the USE database statement or the default database if no USE database statement has been issued for a given instance. SQL Server Profiler displays the name of the database if the ServerName data column is captured in the trace and the server is available. Determine the value for a database by using the DB_ID function.3Yes
DatabaseNamenvarcharName of the database in which the user statement is running.35Yes
EventClassintType of event = 127.27No
EventSequenceintSequence of a given event within the request.51No
EventSubClassintType of event subclass.

1=Spill begin

2=Spill end
21Yes
GroupIDintID of the workload group where the SQL Trace event fires.66Yes
HostNamenvarcharName of the computer on which the client is running. This data column is populated if the client provides the host name. To determine the host name, use the HOST_NAME function.8Yes
IsSystemintIndicates whether the event occurred on a system process or a user process. 1 = system, 0 = user.60Yes
LoginNamenvarcharName of the login of the user (either SQL Server security login or the Windows login credentials in the form of <DOMAIN>\<username>).11Yes
LoginSidimageSecurity identification number (SID) of the logged-in user. You can find this information in the syslogins table of the master database. Each SID is unique for each login in the server.41Yes
NTDomainNamenvarcharWindows domain to which the user belongs.7Yes
NTUserNamenvarcharWindows user name.6Yes
ObjectIDintSystem-assigned ID of the object. Corresponds with the Node ID in Showplans.22Yes
RequestIDintID of the request containing the statement.49Yes
ServerNamenvarcharName of the instance of SQL Server being traced.26No
SessionLoginNamenvarcharLogin name of the user who originated the session. For example, if you connect to SQL Server using Login1 and execute a statement as Login2, SessionLoginName shows Login1 and LoginName shows Login2. This column displays both SQL Server and Windows logins.64Yes
SPIDintID of the session on which the event occurred.12Yes
StartTimedatetimeTime at which the event started, if available.14Yes
TransactionIDbigintSystem-assigned ID of the transaction.4Yes
XactSequencebigintToken that describes the current transaction.50Yes

sp_trace_setevent (Transact-SQL)
Set Index Options
ALTER INDEX (Transact-SQL)

Community Additions

ADD
Show:
© 2016 Microsoft