Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 29655 invoked from network); 16 Aug 2006 02:35:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 16 Aug 2006 02:35:16 -0000 Received: (qmail 22549 invoked by uid 500); 16 Aug 2006 02:35:15 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 22343 invoked by uid 500); 16 Aug 2006 02:35:15 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 22334 invoked by uid 99); 16 Aug 2006 02:35:15 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Aug 2006 19:35:15 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [209.237.227.198] (HELO brutus.apache.org) (209.237.227.198) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Aug 2006 19:35:14 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 5437B7142CF for ; Wed, 16 Aug 2006 02:32:15 +0000 (GMT) Message-ID: <31315670.1155695535342.JavaMail.jira@brutus> Date: Tue, 15 Aug 2006 19:32:15 -0700 (PDT) From: "A B (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Closed: (DERBY-754) Push ON clause predicates down when optimizing SELECT queries. In-Reply-To: <2083329818.1134406305861.JavaMail.jira@ajax.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ http://issues.apache.org/jira/browse/DERBY-754?page=all ] A B closed DERBY-754. --------------------- > Push ON clause predicates down when optimizing SELECT queries. > -------------------------------------------------------------- > > Key: DERBY-754 > URL: http://issues.apache.org/jira/browse/DERBY-754 > Project: Derby > Issue Type: Improvement > Components: Performance > Affects Versions: 10.2.0.0, 10.1.2.0, 10.1.2.1 > Reporter: A B > Attachments: d754_draft.patch > > > 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 > LEFT OUTER JOIN ( > 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: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira