Why are SQL execution plans generally interpreted right to left? [closed]

Posted on

Question :

Why are SQL query/execution plans generally interpreted right to left?

English is a left-to-right written language. Even if for some reason SQL was working out the plan backwards, the data is still just pixels on the screen.

No reason not to display it left-to-right.

Answer :

Execution plans aren’t “read” right to left, one could say they aren’t read at all as they aren’t text. They just display something which can be interpreted in several ways.

The data flows from right to left, but one could just as well “read” them from left to right as the leftmost operator calls GetNext() on the operator to the right so it all depends on what you call reading. (See Showplan Logical and Physical Operators Reference)

Each operator calls getnext until the condition the operator requires is fulfilled. For example a TOP 1 operator calls getnext to the right operator which subsequentally calls getnext to the next operator until it receives one row, then it stops calling the next operator and if that’s it the query finishes.

If your issue is with how it is displayed you could look at plan explorer, which allows for more display options than SSMS as Aaron suggested.

Leave a Reply

Your email address will not be published.