Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 16874 invoked from network); 5 Aug 2009 04:54:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 5 Aug 2009 04:54:29 -0000 Received: (qmail 73974 invoked by uid 500); 5 Aug 2009 04:54:36 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 73917 invoked by uid 500); 5 Aug 2009 04:54:35 -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 73909 invoked by uid 99); 5 Aug 2009 04:54:35 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Aug 2009 04:54:35 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [63.82.107.6] (HELO red.amberpoint.com) (63.82.107.6) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Aug 2009 04:54:27 +0000 Received: from [127.0.0.1] ([10.10.12.207]) by red.amberpoint.com (8.13.8/8.13.8) with ESMTP id n754s6UJ006550 for ; Tue, 4 Aug 2009 21:54:06 -0700 Message-ID: <4A79106D.6040504@amberpoint.com> Date: Tue, 04 Aug 2009 21:54:05 -0700 From: Bryan Pendleton User-Agent: Thunderbird 2.0.0.22 (Windows/20090605) MIME-Version: 1.0 To: Derby Discussion Subject: Re: Filtering using the sort order on two columns References: <4A7842C1.2030800@amberpoint.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org >> SELECT field, text, docfreq FROM Terms >> WHERE field > ? >> ORDER BY field ASC, text ASC >> >> SELECT field, text, docfreq FROM Terms >> WHERE (field = ? AND text > ?) >> ORDER BY field ASC, text ASC >> >> Does each query, separately, use the index as you expect? > > Indeed, both of these queries (even the one with only >) do an index > scan instead of a table scan. Great! Can you construct a UNION of the two queries, and then ORDER BY the UNION? And, in that case, does it use the index for both the union-ed subqueries? thanks, bryan