Fetch Query
Introduction
The Fetch Query “operator” is not actually an operator. It is the equivalent of the Language Element “operator” for one of the two queries contained in a cursor definition. The Fetch Query operator is not used in an execution plan with run-time statistics (“actual execution plan”), but only in an execution plan only (“estimated execution plan”).
The Fetch Query “operator” is the second of the two child operators of a Fast Forward, Keyset, or Snapshot “operator” in the execution plan only for any static or keyset cursor, as well as some fast forward cursors, or the only child operator of a Dynamic or Fast Forward “operator” for any dynamic cursor, as well as the remaining fast forward cursors. The Fetch Query “operator” then serves as the parent operator for the execution plan to be executed when a FETCH statement executes.
The task of the execution plan attached to Fetch Query is to return the requested row from the cursor, by reading from the snapshot created by Population Query (for static cursors and some fast forward cursors), from the actual tables referenced by the cursor (for dynamic cursors and the remaining fast forward cursors), or a combination of the two sources (for keyset cursors).
Visual appearance in execution plans
Depending on the tool being used, the Fetch Query “operator” is displayed in a graphical execution plan as shown below:
|
SSMS and VS Code |
Legacy SSMS |
Plan Explorer |
Paste The Plan |
Algorithm
The Fetch Query “operator” is “executed” when a FETCH statement for the cursor is executed. The logic of this execution can be thought of as follows, although it is unlikely to be actually implemented like this.
Read row
Executing the subtree of a Fetch Query operator results in either a row returned, or the end of data signal returned. Because the FETCH statements is intended to return just that single row (or nothing), execution does not iterate. The row (or end of data signal) returned by the subtree is returned to the FETCH statement.
Operator properties
Since Fetch Query is not an actual operator, it does not have its own properties. However, it is used in the execution plan as a container for all properties that apply to the execution plan as a whole. The full list of these properties can be found here.
SQL Server Management Studio additionally also shows a property Description, with a description of what the Fetch Query operator does: “The query used to retrieve rows when a fetch is issued against a cursor.” This text is provided by SQL Server Management Studio itself, it is not actually part of the execution plan XML.
Change log
(Does not include minor changes, such as adding, removing, or changing hyperlinks, correcting typos, and rephrasing for clarity).
May 29, 2026: Added.
