Return-Path: X-Original-To: apmail-db-derby-user-archive@www.apache.org Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1132CD2E2 for ; Mon, 6 Aug 2012 16:39:46 +0000 (UTC) Received: (qmail 35645 invoked by uid 500); 6 Aug 2012 16:39:45 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 35621 invoked by uid 500); 6 Aug 2012 16:39:45 -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 35614 invoked by uid 99); 6 Aug 2012 16:39:45 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Aug 2012 16:39:45 +0000 X-ASF-Spam-Status: No, hits=-5.0 required=5.0 tests=FSL_RCVD_USER,RCVD_IN_DNSWL_HI,SPF_PASS,UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of dag.wanvik@oracle.com designates 141.146.126.227 as permitted sender) Received: from [141.146.126.227] (HELO acsinet15.oracle.com) (141.146.126.227) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Aug 2012 16:39:37 +0000 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by acsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q76GdGA9019725 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 6 Aug 2012 16:39:17 GMT Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q76GdGqC029002 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 6 Aug 2012 16:39:16 GMT Received: from abhmt102.oracle.com (abhmt102.oracle.com [141.146.116.54]) by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q76GdGUq020144 for ; Mon, 6 Aug 2012 11:39:16 -0500 Received: from localhost (/10.172.139.217) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Aug 2012 09:39:15 -0700 From: dag.wanvik@oracle.com (Dag H. Wanvik) To: "Derby Discussion" Subject: Re: Speeding up Derby for very large queries? References: <34261725.post@talk.nabble.com> Date: Mon, 06 Aug 2012 18:39:11 +0200 In-Reply-To: <34261725.post@talk.nabble.com> (TXVanguard's message of "Mon, 6 Aug 2012 08:16:34 -0700 (PDT)") Message-ID: User-Agent: Gnus/5.110017 (No Gnus v0.17) Emacs/24.0.96 (usg-unix-v) MIME-Version: 1.0 Content-Type: text/plain X-Source-IP: acsinet21.oracle.com [141.146.126.237] X-Virus-Checked: Checked by ClamAV on apache.org TXVanguard writes: > Here is an example of part of a typical query (some names have been changed > to protect the innocent) that I deal with: > > This query is actually only a sub-query that is joined by a UNION to an even > larger sub-query to form a full query. > > The full query takes over a minute to run in Derby, but only a few tenths of > a second in Access. Is there any hope of speeding up these types of > queries in Derby, or is Derby simple not sophisticated enough to perform the > types of optimizations required to speed up complicated, multi-level > queries? (Please note: this is not an attack on Derby. Derby has > applications where it is very useful, but I'm wondering if my particular > application is simply too much for Derby to handle.) Hard to say. In general the Derby optimized is cost based, and for the optimizer to work correctly, the table statistics must be up to date, cf. http://db.apache.org/derby/docs/10.9/tuning/ctunperfstatistics.html Even so, sometimes, the chosen execution plan may not be optimal for somequeries. It is also possible to look at the execution plan and figure out why it isn't performing optimally. http://db.apache.org/derby/docs/10.9/tuning/ttundepth33391.html If Derby is doing the wrong this, one can sometimes override the optimizer's decisions: http://db.apache.org/derby/docs/10.9/tuning/ctundepthoptover.html Good luck! Thanks, Dag