Re: [INTERFACES] Re: Index unused with OR?

From: Hannu Krosing <hannu(at)trust(dot)ee>
To: Olaf Mittelstaedt <mstaedt(at)va-sigi(dot)va(dot)fh-ulm(dot)de>
Cc: pgsql-interfaces(at)postgreSQL(dot)org
Subject: Re: [INTERFACES] Re: Index unused with OR?
Date: 1998-05-14 15:10:02
Message-ID: 355B094A.43F1DAAE@trust.ee
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Olaf Mittelstaedt wrote:

This is probably the wrong list, but ...

> Actually, I discovered the problem using a table containg more than
> 8000 rows, using the latest release 6.3.2.
>
> > Not using the index in OR queries was some-time ago a bug in
> > PostgreSQL 6.1 if my memory is good. Think that has been solved in
> > new releases, am I wrong ?

seems _not_ to be fixed :(

> VACUUM
> w=> explain select * from p where m = 29000;
> NOTICE: QUERY PLAN:
>
> Index Scan on p (cost=0.00 size=0 width=10)
>
> EXPLAIN
> w=> explain select * from p where (m=29000) or (m=30000);
> NOTICE: QUERY PLAN:
>
> Seq Scan on p (cost=0.00 size=0 width=10)
>

As a work-around try

select * from p where (m=29000) union select * from p where (m=30000);

it should be much faster.

Btw, EXPLAIN thinks this to cost nothing ;)

Unique (cost=0.00 size=0 width=0)
-> Sort (cost=0.00 size=0 width=0)
-> Append (cost=0.00 size=0 width=0)

Hannu

In response to

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Olaf Mittelstaedt 1998-05-14 16:53:52 Re: [INTERFACES] Re: Index unused with OR?
Previous Message Peter Mount 1998-05-14 15:04:44 RE: [INTERFACES] JDBC-driver for postgresql