db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rick Hillegas (JIRA)" <derby-...@db.apache.org>
Subject [jira] Commented: (DERBY-754) Push ON clause predicates down when optimizing SELECT queries.
Date Tue, 13 Dec 2005 02:32:45 GMT
    [ http://issues.apache.org/jira/browse/DERBY-754?page=comments#action_12360277 ] 

Rick Hillegas commented on DERBY-754:

Pushing down ON clause fragments has to be done carefully. This is because you cannot arbitrarily
mix the conjuncts from ON and WHERE clauses. In general, outer join operators do NOT commute
and associate--unlike the inner join operator. That is, you can't arbitrarily rearrange the
join order if it involves an outer join. Just a gentle warning about the complexity of outer

> Push ON clause predicates down when optimizing SELECT queries.
> --------------------------------------------------------------
>          Key: DERBY-754
>          URL: http://issues.apache.org/jira/browse/DERBY-754
>      Project: Derby
>         Type: Improvement
>   Components: Performance
>     Versions:,,
>     Reporter: A B
>     Assignee: A B

> In cases where a SELECT subquery occurs as one of the operands to a Join, it is sometimes
beneficial to push join predicates down to the subquery, which allows the optimizer to find
a better access path for the subquery and thus can improve query performance.
> For example, take the following query:
> SELECT  t1.a, t1.b, temp.c
> FROM t1
>     SELECT c,d
>     FROM t2
>   ) as temp
>   ON
>     t1.a = temp.d
>     and temp.d = 8
> ;
> Currently, when optimizing the inner SELECT query, Derby will only pass the inner SELECT's
WHERE predicates to the optimizer--the outer ON predicates are ignored.  Thus, in this case,
the optimizer will have no predicates to work with and so will do a table scan on t2.
> If, however, Derby were to push the "temp.d = 8" predicate down into the inner SELECT
query, the optimizer could use that predicate to make a smarter decision.  For example, if
a primary key existed on column "d" in T2, the optimizer could use that and then choose to
do an index/hash scan when reading t2 (instead of a table scan).
> Not only does can this kind of "pushing" lead to faster reading of tables, but in some
cases where the predicate being pushed references two tables, it can also influence the optimizer's
choice of join strategy, which can in turn lead to improved performance.

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

View raw message