Re: seqscan instead of index scan

From: Chester Kustarz <chester(at)arbor(dot)net>
To: Martin Sarsale <martin(at)emepe3(dot)net>
Cc: Bruno Wolff III <bruno(at)wolff(dot)to>, <pgsql-performance(at)postgresql(dot)org>
Subject: Re: seqscan instead of index scan
Date: 2004-09-01 15:47:32
Message-ID: Pine.BSO.4.44.0409011142140.23931-100000@detroit.arbor.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Mon, 30 Aug 2004, Martin Sarsale wrote:
> "Multicolumn indexes can only be used if the clauses involving the
> indexed columns are joined with AND. For instance,
>
> SELECT name FROM test2 WHERE major = constant OR minor = constant;

You can use DeMorgan's Theorem to transform an OR clause to an AND clause.

In general:
A OR B <=> NOT ((NOT A) AND (NOT B))

So:

> But I need something like:
>
> select * from t where c<>0 or d<>0;

select * from t where not (c=0 and d=0);

I haven't actually tried to see if postgresql would do anything
interesting after such a transformation.

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Josh Berkus 2004-09-01 16:32:24 Re: Changing the column length
Previous Message G u i d o B a r o s i o 2004-09-01 15:07:39 Re: slower every day