ns******@gmail.com wrote:
In oracle, there is a performance improvement if scalar subqueries are
used instead of joins. Does this hold good for Db2 (8.2) too?
Inherently a scalar subquery is not a join.
I.e. a scaar subquery will raise an error if more than one match is
found. You cannot (easily) model that with an OUTER JOIN (you need the
OUTER to handle the NULL)
DB2 will convert scalar subqueries to outer joins (with some spice added
for semantics as noted above) at its own discretion.
So obviously in DB2 a scalar subquery is far from "always better".
Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab