Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 47318 invoked from network); 19 Feb 2009 15:37:00 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Feb 2009 15:37:00 -0000 Received: (qmail 1155 invoked by uid 500); 19 Feb 2009 15:36:58 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 1132 invoked by uid 500); 19 Feb 2009 15:36:58 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 1123 invoked by uid 99); 19 Feb 2009 15:36:58 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Feb 2009 07:36:58 -0800 X-ASF-Spam-Status: No, hits=-4.0 required=10.0 tests=RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [192.18.6.21] (HELO gmp-eb-inf-1.sun.com) (192.18.6.21) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Feb 2009 15:36:48 +0000 Received: from fe-emea-10.sun.com (gmp-eb-lb-1-fe3.eu.sun.com [192.18.6.10]) by gmp-eb-inf-1.sun.com (8.13.7+Sun/8.12.9) with ESMTP id n1JFaDIG022402 for ; Thu, 19 Feb 2009 15:36:25 GMT MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Received: from conversion-daemon.fe-emea-10.sun.com by fe-emea-10.sun.com (Sun Java(tm) System Messaging Server 7.0-3.01 64bit (built Dec 23 2008)) id <0KFB00A00KJBPN00@fe-emea-10.sun.com> for derby-user@db.apache.org; Thu, 19 Feb 2009 15:36:13 +0000 (GMT) Received: from localhost ([unknown] [129.159.112.134]) by fe-emea-10.sun.com (Sun Java(tm) System Messaging Server 7.0-3.01 64bit (built Dec 23 2008)) with ESMTPSA id <0KFB00ET8KO3IDF0@fe-emea-10.sun.com>; Thu, 19 Feb 2009 15:36:04 +0000 (GMT) Date: Thu, 19 Feb 2009 16:34:51 +0100 From: Knut Anders Hatlen Subject: Re: Query Compilation Drastically Increased on Join In-reply-to: <64A84ACFB244464D8C7086F909034D540DB3D830@athena.isdwhq.com> Sender: Knut.Hatlen@Sun.COM To: Derby Discussion Cc: "msegel@segel.com" Message-id: Organization: Sun Microsystems Content-transfer-encoding: QUOTED-PRINTABLE References: <64A84ACFB244464D8C7086F909034D540DB3D80C@athena.isdwhq.com> <20090218200143.947DD5D721@dbrack01.segel.com> <64A84ACFB244464D8C7086F909034D540DB3D830@athena.isdwhq.com> User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.90 (usg-unix-v) X-Virus-Checked: Checked by ClamAV on apache.org "Dustin T. Clifford" writes: > Michael, > > I agree with you that it is not =E2=80=98simple=E2=80=99 and we do = have plans to > optimize this query amongst others. > > The question still remains to me though, why after adding 1 or 2 > tables (the query had 8 tables joined before) does the compile time > jump so drastically when the execution time remains, approximately, > the same. Hi Dustin, If you go from 8 tables to 10 tables in the join the number of possib= le join orders increases 90 times (from 40320 to 3628800). In addition t= o the join orders, the optimizer will have to pick table scan or index scan for each of the tables, which increases the difference in the complexity further as you add more tables. It is this combinatorial explosion that increases the compilation time. However, even if it requires a lot more work from the compiler to find the best execution plan, the actual plan doesn't have to be that much more expensive. So= I don't think it's unreasonable that the execution time increases less than the compilation time as the complexity increases. 12 minutes does sound like a long time, though. Perhaps not a long ti= me if the compilation performs an exhaustive search for the best plan gi= ven the large number of possible combinations, but I was under the impression that the optimizer would time out if the compilation took = too long and just take the best plan that it has found so far. I'm not su= re exactly how it determines that it should time out. Perhaps someone el= se knows? --=20 Knut Anders