Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 88229 invoked from network); 4 Oct 2005 21:43:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 4 Oct 2005 21:43:12 -0000 Received: (qmail 3671 invoked by uid 500); 4 Oct 2005 21:43:11 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 3651 invoked by uid 500); 4 Oct 2005 21:43:11 -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: "Derby Development" Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 3637 invoked by uid 99); 4 Oct 2005 21:43:11 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=SPF_FAIL X-Spam-Check-By: apache.org Received: from [192.87.106.226] (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Oct 2005 14:43:10 -0700 Received: from ajax.apache.org (ajax.apache.org [127.0.0.1]) by ajax.apache.org (Postfix) with ESMTP id C3DFD222 for ; Tue, 4 Oct 2005 23:42:49 +0200 (CEST) Message-ID: <1518330454.1128462169786.JavaMail.jira@ajax.apache.org> Date: Tue, 4 Oct 2005 23:42:49 +0200 (CEST) From: "Satheesh Bandaram (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Commented: (DERBY-558) Optimizer hangs with query that uses more than 6 tables and does subquery flattening. In-Reply-To: <1867432676.1126214910369.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-558?page=comments#action_12331322 ] Satheesh Bandaram commented on DERBY-558: ----------------------------------------- Merged to 10.1 branch. Should be part of 10.1.2 release. > Optimizer hangs with query that uses more than 6 tables and does subquery flattening. > ------------------------------------------------------------------------------------- > > Key: DERBY-558 > URL: http://issues.apache.org/jira/browse/DERBY-558 > Project: Derby > Type: Bug > Versions: 10.1.1.0, 10.0.2.1, 10.0.2.0, 10.1.2.0, 10.2.0.0, 10.0.2.2 > Environment: Running query in "ij" with derby.optimizer.noTimeout=true > Reporter: A B > Assignee: A B > Fix For: 10.1.2.0, 10.2.0.0 > Attachments: d558.patch, repro.sql > > I was running a query that has a large number (hundreds) of tables in it and I set the derby property "derby.optimizer.noTimeout" to true to see what plan Derby would choose as the _best_ plan for the query. When doing so, I ran into a situation where the optimizer hung forever--which is wrong. I expect that setting "noTimeout" to true might cause the query to run more slowly (since it has to evaluate ALL possible join orders for all of the tables in question), but it should _not_ cause the optimizer to hang forever. > I noticed that "subquery flattening" is peformed on the query, which introduces dependencies between the various tables and thus restricts the possible join orders that the optimizer can choose (see http://db.apache.org/derby/docs/10.1/tuning/ctuntransform25868.html). I was eventually able to track the problem down to code in OptimizerImpl where, for queries with more than 6 tables, a certain "jumping" algorithm is used to try to allow the optimizer to find a better plan more quickly. > Long story short, there is logic in the "jumping" mechanism that tries to put the tables into a legal join order, but in certain (rare) cases where multiple join order dependencies have to be enforced, the jump logic can end up looping indefinitely, causing the "hang" in the optimizer. -- 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