• I agree with the previous comments - great article!

    jim.jaggers1 (9/7/2010)


    Can you help me understand the difference in the Nested Loops operator between the first and second plan? Other than the '!' point warning symbol in the first plan they look the same to me. How can you tell one is doing a Cartesion Join while the other is doing an Inner join?

    The exclamation point symbol is not related. This simply indicates an warning from the optimzier - usually an indication of missing statistics.

    In the exectution plan, you can find the difference by checking the properties of the operators (you can see them by hovering your mouse over them, or by right-clicking, selecting "properties", then clicking the operators you want to check).

    If the filtering is done before the join, then you will see a "predicate" property on the scan before (to the right of) the join operator. (Or a "seek predicate" property if it's a seek). In this case, the join itsself is technically still a cartesian join, but on pre-filtered inputs (as if you write ... FROM (SELECT ... WHERE ...) AS a JOIN (SELECT ... WHERE ...) AS b ON ...)

    If the filtering is done during the join, then you will see a "predicate" property and/or "outer references" property on the join operator. This is a true non-cartesian join (inner join, unless the operator is an outer join operator).

    If the filtering is done after the join, you'll see a "predicate" or similar property on one of the operators after (to the left of) the join operator. Usually a filter operator. In these cases, the join was a "true" cartesian product.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/