Re: Index non-usage problem in 8.2.9 - Mailing list pgsql-general

From Tom Lane
Subject Re: Index non-usage problem in 8.2.9
Date
Msg-id 12690.1220416272@sss.pgh.pa.us
Whole thread Raw
In response to Re: Index non-usage problem in 8.2.9  (Joseph S <jks@selectacast.net>)
List pgsql-general
Joseph S <jks@selectacast.net> writes:
> Actually sacode is an int2.

Ah.  8.2 is not very good at proving cross-type predicate conditions,
because it lacks the concept of an operator family.  You need to declare
the index this way:

create index d2i on d2 (sgcode, sacode)
  WHERE sacode IS NOT NULL AND sacode > 0::int2;

(As previously noted, you don't really need the IS NOT NULL part of the
condition, but that isn't what's causing the problem here.)

            regards, tom lane

pgsql-general by date:

Previous
From: Artacus
Date:
Subject: Re: Oracle and Postgresql
Next
From: aderose
Date:
Subject: Re: vacuum analyze hurts performance