Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 74106 invoked from network); 5 Aug 2009 22:31:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 5 Aug 2009 22:31:32 -0000 Received: (qmail 95558 invoked by uid 500); 5 Aug 2009 22:31:37 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 95429 invoked by uid 500); 5 Aug 2009 22:31:37 -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 95368 invoked by uid 99); 5 Aug 2009 22:31:37 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Aug 2009 22:31:37 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Aug 2009 22:31:35 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id DFD2329A0015 for ; Wed, 5 Aug 2009 15:31:14 -0700 (PDT) Message-ID: <2045344040.1249511474915.JavaMail.jira@brutus> Date: Wed, 5 Aug 2009 15:31:14 -0700 (PDT) From: "Mike Matrigali (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Updated: (DERBY-4339) improve sort avoidance algorithm to include equijoin relationships In-Reply-To: <1392658460.1249507757280.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/DERBY-4339?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Mike Matrigali updated DERBY-4339: ---------------------------------- Here is another example of a query that could do sort avoidance with added code properly taking into acount equijoin relationships: select * from TENKTUP1, TENKTUP2 where TENKTUP1.unique1 = TENKTUP2.unique1 order by TENKTUP1.unique1 = TENKTUP2.unique1 The optimizer could pick either TENKTUP1.unique1 or TENKTUP2.unique1 as the outermost node and then because it knows that TENKTUP1.unique1 = TENKTUP2.unique1 it would know that the query also satisfies order by TENKTUP1.unique1 = TENKTUP2.unique1 without doing an additional sort. > improve sort avoidance algorithm to include equijoin relationships > ------------------------------------------------------------------ > > Key: DERBY-4339 > URL: https://issues.apache.org/jira/browse/DERBY-4339 > Project: Derby > Issue Type: Improvement > Components: SQL > Reporter: Mike Matrigali > Priority: Minor > > Not all sort avoidance paths are recognized by the optimizer. Here is an example of the class targeted by this issue, from > the wisc tests : > select * from --DERBY-PROPERTIES joinOrder=FIXED > TENKTUP2, TENKTUP1 > where TENKTUP1.unique1 = TENKTUP2.unique1 > and TENKTUP2.unique1 < 2500 > order by TENKTUP1.unique1'; > There is a unique index on TENKTUP1.unique1 and TENKTUP2.unique1. To exercise the path, the plan > forces TENKTUP2 as outermost join, knows that query result is sorted on TENKTUP2.unique1, but does not > recognize that because "TENKTUP1.unique1 = TENKTUP2.unique1" that query is also sorted on TENKTUP1.unique1 and could avoid a sort. > Note without the fixed join order a sort avoidance plan is picked by choosing the plan where TENKTUP1.unique1 is the > outermost node. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.