Re: Extending my question. Was: The relational model and relational algebra - why did SQL become the industry standard?

From: Lauri Pietarinen <lauri.pietarinen_at_atbusiness.com>
Date: Tue, 04 Mar 2003 15:55:25 +0200
Message-ID: <3E64B04D.3010701_at_atbusiness.com>


Paul Vernon wrote:

>Pass, but it's interesting to note that given the EXISTS form of the query,
>DB2 optimises it to the same query as before.
>
>
>Original Statement:
>------------------
>SELECT P#, PNAME
>FROM P
>WHERE EXISTS
> (SELECT *
> FROM SP
> WHERE P.P# = SP.P#)
>
>
>Optimized Statement:
>-------------------
>SELECT DISTINCT Q2.P# AS "P#", Q2.PNAME AS "PNAME"
>FROM DB2.SP AS Q1, DB2.P AS Q2
>WHERE (Q2.P# = Q1.P#)
>

So it basically converts 'EXISTS' into a special kind of join....

Regards,
Lauri Pietarinen Received on Tue Mar 04 2003 - 14:55:25 CET

Original text of this message