Received: from mailex.rz.fh-ulm.de (Mailex.rz.fh-ulm.de [141.59.42.15]) by hub.org (8.8.8/8.7.5) with ESMTP id JAA24688 for ; Thu, 14 May 1998 09:22:09 -0400 (EDT) Received: from gate.va.fh-ulm.de (gate.va.fh-ulm.de [141.59.15.1]) by mailex.rz.fh-ulm.de (8.8.8/8.8.8) with SMTP id PAA07003 for ; Thu, 14 May 1998 15:22:56 +0200 Received: by gate.va.fh-ulm.de (8.6.11) id PAA04595; Thu, 14 May 1998 15:21:57 +0200 Message-Id: <199805141321.PAA04595@gate.va.fh-ulm.de> Received: from va-sigi.va.fh-ulm.de(141.59.12.12) by gate.va.fh-ulm.de via smap (V1.3) id sma004592; Thu May 14 15:21:34 1998 Received: from VA-SIGI/SpoolDir by va-sigi.va.fh-ulm.de (Mercury 1.21); 14 May 98 15:21:21 +0200 Received: from SpoolDir by VA-SIGI (Mercury 1.21); 14 May 98 15:21:03 +0200 From: "Olaf Mittelstaedt" Organization: Verwaltung FH Ulm To: pgsql-interfaces@postgresql.org Date: Thu, 14 May 1998 15:20:56 +0100 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Index unused with OR? Priority: normal Hello all, playing around with the latest ODBC driver I noticed very slow answers when using OR with an indexed column in the WHERE part of a SELECT. To verify this I tried the following directly with psql on the database server: postgres=> create database test7; CREATEDB postgres=> \c test7 connecting to new database: test7 test7=> create table t7(i1 int4,i2 int4); CREATE test7=> create unique index i_t7 on t7(i1); CREATE test7=> insert into t7 values(1,2); INSERT 53741 1 test7=> insert into t7 values(2,3); INSERT 53742 1 test7=> insert into t7 values(3,4); INSERT 53743 1 test7=> explain select * from t7 where i1=1; NOTICE: QUERY PLAN: Index Scan on t7 (cost=0.00 size=0 width=8) EXPLAIN test7=> explain select * from t7 where (i1=1) or (i1=2); NOTICE: QUERY PLAN: Seq Scan on t7 (cost=0.00 size=0 width=8) EXPLAIN Obviously the index isn't used. Both PostgreSQL 6.3.1 and 6.3.2 are suffering from this problem. Any help or hints? Regards, Olaf -- Olaf Mittelstaedt - IuK - mittelstaedt@fh-ulm.de Fachhochschule Ulm Prittwitzstr. 10 89075 Ulm Tel.: +49 (0)731-502-8220 Fax: -8270 Nemo me impune lacessit.