Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 8605 invoked from network); 27 Jun 2008 15:11:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 27 Jun 2008 15:11:13 -0000 Received: (qmail 11585 invoked by uid 500); 27 Jun 2008 15:11:13 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 11562 invoked by uid 500); 27 Jun 2008 15:11:13 -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 11551 invoked by uid 99); 27 Jun 2008 15:11:13 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Jun 2008 08:11:13 -0700 X-ASF-Spam-Status: No, hits=-1.0 required=10.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [192.18.6.24] (HELO gmp-eb-inf-2.sun.com) (192.18.6.24) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Jun 2008 15:10:21 +0000 Received: from fe-emea-10.sun.com (gmp-eb-lb-2-fe1.eu.sun.com [192.18.6.10]) by gmp-eb-inf-2.sun.com (8.13.7+Sun/8.12.9) with ESMTP id m5RFAd4a026126 for ; Fri, 27 Jun 2008 15:10:39 GMT Received: from conversion-daemon.fe-emea-10.sun.com by fe-emea-10.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) id <0K3400801N0ZO900@fe-emea-10.sun.com> (original mail from Knut.Hatlen@Sun.COM) for derby-user@db.apache.org; Fri, 27 Jun 2008 16:10:39 +0100 (BST) Received: from localhost ([129.159.112.134]) by fe-emea-10.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) with ESMTPSA id <0K3400LUDNHO8D10@fe-emea-10.sun.com> for derby-user@db.apache.org; Fri, 27 Jun 2008 16:10:37 +0100 (BST) Date: Fri, 27 Jun 2008 17:10:36 +0200 From: Knut Anders Hatlen Subject: Re: Pathologically poor query performance - advice required In-reply-to: <4864374B.9040803@papercut.com> Sender: Knut.Hatlen@Sun.COM To: Derby Discussion Message-id: Organization: Sun Microsystems MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT References: <4861D93B.9060900@papercut.com> <48626EEF.5060709@gmail.com> <4862F8AC.80406@papercut.com> <4863B41B.10208@sbcglobal.net> <4864374B.9040803@papercut.com> User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/22.2 (usg-unix-v) X-Virus-Checked: Checked by ClamAV on apache.org Matt Doran writes: >> To get feedback from people it may also help to post the ddl of the >> tables in the query, including the indexes/constraints. I know you >> provided the db, so with work it is available - but the more up front >> info you provide the more help possible. > I've attached the database creation script if anyone is interested. >> >> One other suggestion might be to try the query once with no optimizer >> timeout to see if it would have found a better plan: >> http://wiki.apache.org/db-derby/PerformanceDiagnosisTips >> > I tried disabling the optimizer timeout, it had not effect. It was > the maxMemoryPerTable that had the impact here. Another thing that may affect which plan the optimizer chooses, I think, is the size of the Java heap. Also, when the optimizer checks how much memory it has available, it looks at the current size of the Java heap, not at how much the heap is allowed to grow. So say you've allowed the heap to grow to 512MB by specifying -Xmx512M on the command line, Derby doesn't see that it has that amount of memory available until the heap has actually grown to that size. And the heap doesn't normally grow until garbage collection cannot free enough memory. To ensure that Derby always sees how much memory it has available, also set the minimum heap size with -Xms. Not sure if it helps in your case, but it might be worth a try. -- Knut Anders