Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 66736 invoked from network); 11 Oct 2006 21:20:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 11 Oct 2006 21:20:43 -0000 Received: (qmail 98467 invoked by uid 500); 11 Oct 2006 21:20:42 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 98436 invoked by uid 500); 11 Oct 2006 21:20:41 -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 98425 invoked by uid 99); 11 Oct 2006 21:20:41 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Oct 2006 14:20:41 -0700 X-ASF-Spam-Status: No, hits=1.9 required=10.0 tests=DNS_FROM_RFC_ABUSE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: 32.97.182.145 is neither permitted nor denied by domain of qozinx@gmail.com) Received: from [32.97.182.145] (HELO e5.ny.us.ibm.com) (32.97.182.145) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Oct 2006 14:20:40 -0700 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by e5.ny.us.ibm.com (8.13.8/8.12.11) with ESMTP id k9BLKJT8029735 for ; Wed, 11 Oct 2006 17:20:19 -0400 Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay04.pok.ibm.com (8.13.6/8.13.6/NCO v8.1.1) with ESMTP id k9BLKHbD137094 for ; Wed, 11 Oct 2006 17:20:19 -0400 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id k9BLKG6k001689 for ; Wed, 11 Oct 2006 17:20:16 -0400 Received: from [127.0.0.1] (svl-arbrown.svl.ibm.com [9.30.38.165]) by d01av03.pok.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id k9BLKEu2001581 for ; Wed, 11 Oct 2006 17:20:16 -0400 Message-ID: <452D600E.5000405@gmail.com> Date: Wed, 11 Oct 2006 14:20:14 -0700 From: Army User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.1) Gecko/20040707 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Derby Discussion Subject: Re: Derby Optimizer Hangs References: <97085FEE4C8BDB4AB6FA3E770EBC79BB5552DF@mail1.cyclonecommerce.com> In-Reply-To: <97085FEE4C8BDB4AB6FA3E770EBC79BB5552DF@mail1.cyclonecommerce.com> Content-Type: text/plain; charset=us-ascii; format=flowed 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 Amit Patel wrote: > I ran into a problem with Derby. When I issue a large SQL statement > with lots of WHERE conditions, the Derby optimizer looks like it's in an > infinite loop. Do you know how long the query was running before you took the thread dump? If you repeat the process of running the query and taking the thread dump, do the threads look the same every time? > Does anyone know if this is a bug or can I tune Derby to get around this > issue? It's hard to say with just the info given. From a quick glance it looks like your joining 14 tables in this query. If that's true, the Derby optimizer is going to try out all possible orderings for the 14 tables until it either finishes or "times out". There are known issues in this area that could cause the optimizer to spend a *lot* of time trying to figure out what the best plan is--see for example DERBY-1906, DERBY-1907, DERBY-1905. In such a case it might look like the optimizer has hung when in fact it's just busy trying out all of the various combinations. Since you're using 10.2, one thing you can do is use optimizer overrides to tell the optimizer to skip optimization of join order--i.e. to just join the tables in the order in which they appear in the query. To do that you can specify the "joinOrder" optimizer override as follows: SELECT DISTINCT t0.OID, t0.JDOVERSION, t0.BINARYCOLLABORATIONHASHCODE, ... FROM --DERBY-PROPERTIES joinOrder=FIXED DBA.MESSAGES t0 INNER JOIN DBA.CUSTOMDATA t1 ON t0.OID = t1.MESSAGEOID ... Note that you must have an end-of-line after specifying the joinOrder=FIXED property. If the query completes in a reasonable time with this property set, then it's probably the case that, in your original query, the optimizer is spending time trying out all of the various join orders for the 14 tables. If the query still "hangs" with this property set, then it might be good if you can: 1. Reduce the number of tables and/or WHERE predicates to find the minimum number of tables/predicates required to reproduce the hang. 2. Take note of how long the query actually runs. Is it minutes, hours, days? 3. See the following wiki page for additional suggestions: http://wiki.apache.org/db-derby/PerformanceDiagnosisTips As a general rule, more info is better. The above wiki page describes the kind of information that is most helpful in debugging situations like these. If you can start there, someone (perhaps even you!) may be able to provide further insight as to what's happening in this query... Army