Return-Path: X-Original-To: apmail-db-derby-dev-archive@www.apache.org Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B02D6F9AE for ; Fri, 29 Mar 2013 16:30:34 +0000 (UTC) Received: (qmail 42054 invoked by uid 500); 29 Mar 2013 16:30:34 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 41897 invoked by uid 500); 29 Mar 2013 16:30:34 -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 41869 invoked by uid 99); 29 Mar 2013 16:30:33 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Mar 2013 16:30:33 +0000 X-ASF-Spam-Status: No, hits=0.7 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [66.94.237.184] (HELO nm11-vm1.access.bullet.mail.mud.yahoo.com) (66.94.237.184) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Mar 2013 16:30:25 +0000 Received: from [66.94.237.195] by nm11.access.bullet.mail.mud.yahoo.com with NNFMP; 29 Mar 2013 16:30:02 -0000 Received: from [98.138.104.98] by tm6.access.bullet.mail.mud.yahoo.com with NNFMP; 29 Mar 2013 16:30:02 -0000 Received: from [127.0.0.1] by smtp118.sbc.mail.ne1.yahoo.com with NNFMP; 29 Mar 2013 16:30:02 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sbcglobal.net; s=s1024; t=1364574602; bh=EY2YPfHGvcbkqe62C9abMJanY4/a8cGzthbsYEFsRSU=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:X-Rocket-Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:References:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=RxQh0Sp0XYcWDgFG7pdW9VY/9RTiIdpeufAJeY5gmOuHjucDyXiH+P08Pfj0+EMldPJkfH+HySeJdiegQ9srpegUmGnFGLDnN9zsXeqJV0utgyB6vRUzx/J8GzmSbw9rVgsRfq/RyF2p0aTp2gGyXG+JujElTxVYTPEwpZD6nXs= X-Yahoo-Newman-Id: 730205.5088.bm@smtp118.sbc.mail.ne1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: k_rkUbkVM1k9f1ep9gT0D0PJiGAYRxeC8hva.gkp6sFsLOh sVRcf.b.cuZY_GiXMB9OLbrBpMX6fWIeobFv22UbbuZLikUueAOd.eSfH2.q 5uyzvYpAGSrxIaFB1tkCmoOfsM2fzHmDYVdYizmdFdzNpPWXhN3FXAULb.1W Exc9lREdtSZ2RmGqC7MDVzELzCiRgpNmlQphyYAa1oy2OT4H8WL1AllLfDUF Gy8SCb0oVu5vDBdJye1MFYbtukk8dK3wtpMcWrKCiof0OVRpJI27..JUcBlQ ASbP.rD1Yiz.tj4Qmy3xIlpkgluC2Ey.lUMqWJLM.A1OStcGnO9rSq4GtSgr Hxk.itAmpLS6F9Pev1istzlflFcNvJzUXZ6AYJ3VWXALTEG.XUDVe3xOKf8f ooLTUMVdtmhFBKsxwShDS9_tI2_GG284sODaUd8jrEqSbk0.23tnxEaoaws6 UqGeAmr9wPCoghHLQB05GzCXstxgROAetF6DVIuBam_WJtoxXlaNZBwJgneR KmcFhzoe5tUTzbTSYWvN_7MbR95wlVqjjjQ-- X-Yahoo-SMTP: 0mCmWXSswBCWOCMKYdwRsTx1yUFXw1u4Y1Itob3JXDF8Loh0 X-Rocket-Received: from [192.168.1.37] (mikem_app@24.23.246.126 with plain) by smtp118.sbc.mail.ne1.yahoo.com with SMTP; 29 Mar 2013 16:30:02 +0000 UTC Message-ID: <5155C189.70502@sbcglobal.net> Date: Fri, 29 Mar 2013 09:30:01 -0700 From: Mike Matrigali User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130307 Thunderbird/17.0.4 MIME-Version: 1.0 To: derby-dev@db.apache.org Subject: Re: Why is the optimizer choosing such a bad path References: <97EB699F861AD841B5908C7CA9C9565602699D8230DE@VSERVER1.canoga.com>,<5153713B.706@sbcglobal.net> <97EB699F861AD841B5908C7CA9C9565602698C87D0E2@VSERVER1.canoga.com> <97EB699F861AD841B5908C7CA9C9565602699D823154@VSERVER1.canoga.com> <97EB699F861AD841B5908C7CA9C9565602699D823155@VSERVER1.canoga.com> <97EB699F861AD841B5908C7CA9C9565602699D823158@VSERVER1.canoga.com> <5154B1F0.8080900@sbcglobal.net> <97EB699F861AD841B5908C7CA9C9565602699D823238@VSERVER1.canoga.com> In-Reply-To: <97EB699F861AD841B5908C7CA9C9565602699D823238@VSERVER1.canoga.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org On 3/29/2013 5:28 AM, Bergquist, Brett wrote: > Mike I have a reproducible case but the database is 132GB so it is not practical. I am willing to dig in and try to help debug this. On the issue that was pointed to, Mamta seemed to have used a debug procedure that would print out more information on why the optimizer is choosing what it does. This might be useful in this case as well. > > So if someone can point me in the right area of the code to start looking and adding some debug that would be helpful. I have done some fixes for Derby in the past so I am able to build and debug Derby. > That's great. I am out of my depth debugging optimizer problems, hopefully rick and/or mamta can help with that tool they were working on. I think rick did some work to make it easier to turn on/off using optional tools. From what you have described so far seems key to understand what is the difference in estimates in your original database after running update stats on all tables and when you drop/recreate that index that leads to the behavior change. starting bottom up I can point you at the routines I would expect the optimizer to call to get the number of rows in a table. Making sure these routines are returning reasonable numbers would be a good start. You are looking for getEstimatedRowCount() interfaces. The 2 most interesting implementations are: this one should be called for indexes: java/engine/org/apache/derby/impl/store/access/btre/OpenBTree.java:200: public long getEstimatedRowCount() this one should be called for base tables: java/engine/org/apache/derby/impl/store/access/conglomerate/GenericController.java:180: public long getEstimatedRowCount()