Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 74208 invoked from network); 12 Jan 2009 12:49:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Jan 2009 12:49:35 -0000 Received: (qmail 76411 invoked by uid 500); 12 Jan 2009 12:49:33 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 76388 invoked by uid 500); 12 Jan 2009 12:49:33 -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 76379 invoked by uid 99); 12 Jan 2009 12:49:33 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Jan 2009 04:49:33 -0800 X-ASF-Spam-Status: No, hits=-4.0 required=10.0 tests=RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [192.18.6.24] (HELO gmp-eb-inf-2.sun.com) (192.18.6.24) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Jan 2009 12:49:23 +0000 Received: from fe-emea-09.sun.com (gmp-eb-lb-2-fe3.eu.sun.com [192.18.6.12]) by gmp-eb-inf-2.sun.com (8.13.7+Sun/8.12.9) with ESMTP id n0CCn2Qf009655 for ; Mon, 12 Jan 2009 12:49:02 GMT Received: from conversion-daemon.fe-emea-09.sun.com by fe-emea-09.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) id <0KDC00K01ZF6DV00@fe-emea-09.sun.com> (original mail from Knut.Hatlen@Sun.COM) for derby-user@db.apache.org; Mon, 12 Jan 2009 12:49:02 +0000 (GMT) Received: from localhost ([129.159.112.134]) by fe-emea-09.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) with ESMTPSA id <0KDC00ECCZLIO230@fe-emea-09.sun.com> for derby-user@db.apache.org; Mon, 12 Jan 2009 12:48:55 +0000 (GMT) Date: Mon, 12 Jan 2009 13:49:41 +0100 From: Knut Anders Hatlen Subject: Re: Bad performance with UPDATE on a nested SELECT In-reply-to: <1231761599.3683.18.camel@pc280> Sender: Knut.Hatlen@Sun.COM To: Derby Discussion Message-id: Organization: Sun Microsystems MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT References: <1231761599.3683.18.camel@pc280> User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (usg-unix-v) X-Virus-Checked: Checked by ClamAV on apache.org Mikkel Kamstrup Erlandsen writes: > Hi list, > > I am seeing some bad performance on an UPDATE on a nested SELECT. The > query in case takes about 30s, but I think it should be a lot faster > because the same query on a PostgresQL runs < 1 ms... Anyway, here's the > setup: > > I have two tables 'records' and 'relations'. > > The 'records' table stores a bunch of records along with some metadata. > It has a unique index 'i' on the 'id' column and a normal index 'm' on > the 'mtime' column. This table holds about 1.5M rows. > > The 'relations' table stores parent/child relations between records and > has two rows 'parentId' and 'childId'. There is a unique index 'pc' on > (parentId,childId) and a normal index 'c' on childId. This table holds > about 35k rows. Hi Mikkel, Derby sometimes has problems with the cardinality statistics getting stale in non-unique indexes, which may lead to bad decisions being made by the optimizer. Do you still see the problem if you compress the relations table (alternatively, you could drop the index on childId and recreate it)? If this speeds up the execution, you're probably experiencing these issues: https://issues.apache.org/jira/browse/DERBY-269 https://issues.apache.org/jira/browse/DERBY-3788 -- Knut Anders