Databases Reference
In-Depth Information
We can see that there is only one sort operation (instead of the two required earlier). In
Chapter
4
,
Optimizing SQL Code the Using
subqueries
recipe, we have seen the performance
improvements related to the
HASH
JOIN
RIGHT
ANTI
operation, so we can use this modified
query instead of the original one using the
MINUS
operator.
There's more...
Set operators are very intuitive, because they are related to the Set Theory. However, it's
better to substitute the queries which use
MINUS
and
INTERSECT
with their corresponding
counterparts as we have seen in this recipe (
ANTI-JOIN
and
SELECT
DISTINCT
statements, respectively), because the optimizer can execute them better, in terms of sort
operations required.