[ 
https://issues.apache.org/jira/browse/DERBY-4374?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761498#action_12761498
 ] 

Knut Anders Hatlen commented on DERBY-4374:
-------------------------------------------

The CROSS JOIN operator can be replaced with an INNER JOIN where the join 
clause always evaluates to true, e.g. 1=1. It can also be replaced with a 
sub-query. So equivalent queries will be:

INNER JOIN:

SELECT * FROM CITIES LEFT OUTER JOIN
    FLIGHTS INNER JOIN COUNTRIES ON 1=1
        ON CITIES.AIRPORT = FLIGHTS.ORIG_AIRPORT
            WHERE COUNTRIES.COUNTRY_ISO_CODE = 'US'

Sub-query:

SELECT * FROM CITIES LEFT OUTER JOIN
    (SELECT * FROM FLIGHTS, COUNTRIES) S
        ON CITIES.AIRPORT = S.ORIG_AIRPORT
            WHERE S.COUNTRY_ISO_CODE = 'US'

(Curiously, the queries that use CROSS JOIN or INNER JOIN need more than three 
minutes to complete on the toursdb database, whereas the sub-query variant 
completes in less than ten seconds. Probably an optimizer issue, but at least 
the results are the same.)

> Document the CROSS JOIN operation in the reference manual
> ---------------------------------------------------------
>
>                 Key: DERBY-4374
>                 URL: https://issues.apache.org/jira/browse/DERBY-4374
>             Project: Derby
>          Issue Type: Improvement
>          Components: Documentation
>    Affects Versions: 10.6.0.0
>            Reporter: Knut Anders Hatlen
>            Assignee: Kim Haase
>         Attachments: DERBY-4374-2.diff, DERBY-4374-2.zip, DERBY-4374.diff, 
> DERBY-4374.stat, DERBY-4374.zip
>
>
> CROSS JOIN was added in DERBY-4355. We should document it alongside the other 
> join operations in the reference manual.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to