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 3B617E132 for ; Fri, 1 Mar 2013 13:27:06 +0000 (UTC) Received: (qmail 85780 invoked by uid 500); 1 Mar 2013 13:27:06 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 85764 invoked by uid 500); 1 Mar 2013 13:27:06 -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 85753 invoked by uid 99); 1 Mar 2013 13:27:05 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Mar 2013 13:27:05 +0000 X-ASF-Spam-Status: No, hits=-2.0 required=5.0 tests=FSL_NEW_HELO_USER,RCVD_IN_DNSWL_MED,SPF_PASS,UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of rick.hillegas@oracle.com designates 156.151.31.81 as permitted sender) Received: from [156.151.31.81] (HELO userp1040.oracle.com) (156.151.31.81) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Mar 2013 13:26:54 +0000 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r21DQWw1001246 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 1 Mar 2013 13:26:33 GMT Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r21DQWKn002859 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 1 Mar 2013 13:26:32 GMT Received: from abhmt103.oracle.com (abhmt103.oracle.com [141.146.116.55]) by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id r21DQWDH014479 for ; Fri, 1 Mar 2013 07:26:32 -0600 Received: from dhcp-amer-vpn-rmdc-anyconnect-10-159-104-63.vpn.oracle.com (/10.159.104.63) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 01 Mar 2013 05:26:31 -0800 Message-ID: <5130AC87.4070107@oracle.com> Date: Fri, 01 Mar 2013 05:26:31 -0800 From: Rick Hillegas User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.7; en-US; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11 MIME-Version: 1.0 To: derby-dev@db.apache.org Subject: Re: Is there a way to dump all the plans considered by optimizer into log? References: <86zjyoolo2.fsf@oracle.com> <5130075D.8030509@gmail.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Source-IP: ucsinet21.oracle.com [156.151.31.93] X-Virus-Checked: Checked by ClamAV on apache.org If we decide to make this part of the product, I would recommend using the new optional tools feature rather than adding yet another syscs_diag procedure. New optional tools are easier to add than new system procedures. Something like the following would work: -- this installs optimizer tracing call syscs_util.syscs_register_tool( 'optimizerTracing', true ); ... -- the following procedure, installed by the call above, -- might have some optional string varargs specifying how the output -- should be formatted and where it should be written. -- we could add those args in a later rev when we have more -- experience with this tool. -- but a first rev wouldn't need to be that fancy. call printOptimizerTrace(); -- this turns off optimizer tracing call syscs_util.syscs_register_tool( 'optimizerTracing', false ); I would recommend creating a new JIRA where we can discuss the api for optimizer tracing. Thanks, -Rick On 2/28/13 6:36 PM, Mamta Satoor wrote: > If we do decide to make this available as part of Derby release, the > work can go in as part of existing jira DERBY-837. > > thanks, > Mamta > > On Thu, Feb 28, 2013 at 5:41 PM, Bryan Pendleton > wrote: >>> I didn't find any easy way to enable it (like setting a property). So >>> what I ended up with, was to define two stored procedures: >>> >>> public static void trace() { >>> org.apache.derby.iapi.db.OptimizerTrace.setOptimizerTrace(true); >>> } >>> >>> public static void printTrace() { >>> >>> System.out.println(org.apache.derby.iapi.db.OptimizerTrace.getOptimizerTraceOutput()); >>> } >>> >>> s.execute("create procedure trace() language java parameter style >>> java external name '" + getClass().getName() + ".trace'"); >>> s.execute("create procedure print_trace() language java parameter >>> style java external name '" + getClass().getName() + ".printTrace'"); >>> >>> And then call trace() before the statement to trace, and printTrace() >>> after: >>> >>> s.execute("call trace()"); >>> s.execute("select 1 from sys.sysschemas natural join sys.systables"); >>> s.execute("call print_trace()"); >> >> Might we consider permanently including these, and putting them in, say, >> the SYSCS_DIAG schema, so it would be something like: >> >> s.execute("call SYSCS_DIAG.OPTIMIZER_TRACE(1)"); >> ... >> s.execute("call SYSCS_DIAG.OPTIMIZER_PRINT_TRACE()"); >> s.execute("call SYSCS_DIAG.OPTIMIZER_TRACE(0)"); >> >> thanks, >> >> bryan >>