pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Olaf Mittelstaedt <mstaedt@va-sigi.va.fh-ulm.de>
To: pgsql-interfaces@postgresql.org
Subject: Index unused with OR?
Date: Thu, 14 May 1998 15:20:56 +0100
Message-ID: <199805141321.PAA04595@gate.va.fh-ulm.de> (raw)

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.




view thread (7+ messages)  latest in thread

Message-ID: <199805141321.PAA04595@gate.va.fh-ulm.de>
Permalink:  ../199805141321.PAA04595@gate.va.fh-ulm.de/
Also on:    postgresql.org/message-id/199805141321.PAA04595@gate.va.fh-ulm.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: mstaedt@va-sigi.va.fh-ulm.de
  Subject: Re: Index unused with OR?
  In-Reply-To: <199805141321.PAA04595@gate.va.fh-ulm.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox