Example:
UPDATE t
SET Amount = applied.MaxAmount
FROM @test t
CROSS APPLY
(
SELECT MAX(t2.Amount) AS MaxAmount
FROM @test t2
WHERE t2.Id = t.ForeignId
) AS applied
vs
UPDATE t
SET Amount = applied.MaxAmount
FROM @test t
OUTER APPLY
(
SELECT MAX(t2.Amount) AS MaxAmount
FROM @test t2
WHERE t2.Id = t.ForeignId
) AS applied
It's my understanding that these two scripts will accomplish the same thing since the MAX() function will always return a result even if that result is NULL. But the OUTER APPLY is much slower than the CROSS APPLY when I apply it to a large dataset.
I would like to know why CROSS APPLY is so much faster. Is it just using a more efficient algorithm?