Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 23852 invoked from network); 26 Jan 2006 19:53:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 26 Jan 2006 19:53:37 -0000 Received: (qmail 90115 invoked by uid 500); 26 Jan 2006 19:53:36 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 90091 invoked by uid 500); 26 Jan 2006 19:53:35 -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 90082 invoked by uid 99); 26 Jan 2006 19:53:35 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Jan 2006 11:53:35 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [207.172.4.61] (HELO smtp01.mrf.mail.rcn.net) (207.172.4.61) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Jan 2006 11:53:35 -0800 Received: from 205-178-43-93.s347.tnt1.sfrn.ca.dialup.rcn.com (HELO Nipper.rcn.com) ([205.178.43.93]) by smtp01.mrf.mail.rcn.net with ESMTP; 26 Jan 2006 14:53:13 -0500 X-IronPort-AV: i="4.01,221,1136178000"; d="scan'208"; a="158701279:sNHT99049940" Message-Id: <6.2.3.4.2.20060126114819.039d6ca0@pop.rcn.com> X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 Date: Thu, 26 Jan 2006 11:53:07 -0800 To: From: Jeffrey Lichtman Subject: Re: A few questions about index usage In-Reply-To: <43D9166F.1050504@nic.fi> References: <43D9166F.1050504@nic.fi> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N >1) "SELECT MIN(Id) FROM Customer" and "SELECT MAX(Id) FROM Customer" >are both fast, but "SELECT MIN(Id), MAX(Id) FROM Customer" is slow, >taking 5 seconds. Why? Derby knows how to use an index to quickly find a minimum or a maximum (by traversing down one side of the B-tree or the other). It doesn't know how to do both in the same query, which would take two traversals. >2) "SELECT * FROM Customer ORDER BY Id" is fast but "SELECT * FROM >Customer ORDER BY Id DESC" is slow. Why? Can't it scroll the index backwards? Nope - Derby doesn't do backwards scrolling. I think the physical data layout could support it (i.e. there are backwards pointers), but backwards scrolling has never been implemented. Could someone more familiar with the store confirm this (Mike?). - Jeff Lichtman swazoo@rcn.com Check out Swazoo Koolak's Web Jukebox at http://swazoo.com/