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 13F4CD22D for ; Fri, 28 Sep 2012 04:55:11 +0000 (UTC) Received: (qmail 69466 invoked by uid 500); 28 Sep 2012 04:55:10 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 69415 invoked by uid 500); 28 Sep 2012 04:55:10 -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 69371 invoked by uid 99); 28 Sep 2012 04:55:09 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Sep 2012 04:55:09 +0000 Date: Fri, 28 Sep 2012 15:55:09 +1100 (NCT) From: "Mamta A. Satoor (JIRA)" To: derby-dev@db.apache.org Message-ID: <1749861430.137671.1348808109305.JavaMail.jiratomcat@arcas> In-Reply-To: <1854747400.10357.1300400309752.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Updated] (DERBY-5142) Optimizer uses table scan when it could use index when multiple OR clauses MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/DERBY-5142?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Mamta A. Satoor updated DERBY-5142: ----------------------------------- Urgency: Normal > Optimizer uses table scan when it could use index when multiple OR clauses > -------------------------------------------------------------------------- > > Key: DERBY-5142 > URL: https://issues.apache.org/jira/browse/DERBY-5142 > Project: Derby > Issue Type: Improvement > Components: SQL, Store > Reporter: Karl Wright > Attachments: repro5142.diff > > > The Derby optimizer doesn't seem to recognize that a query like this: > SELECT id,distance,linktype FROM hopcount WHERE (jobid=? AND linktype=? AND parentidhash=?) OR (jobid=? AND linktype=? AND parentidhash=?) > ... might be best planned by using an index declared on hopcount as (jobid,linktype,parentidhash). Instead, a table scan is always used, no matter how big the table. Other databases have no trouble with constructs like this. > This is a very common situation, and blocks Apache ManifoldCF from using Derby as its primary database choice. > I've verified that the index IS successfully used with the same table statistics when the query has only ONE clause, e.g.: > SELECT id,distance,linktype FROM hopcount WHERE (jobid=? AND linktype=? AND parentidhash=?) -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira