Re: Index non-usage problem in 8.2.9

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joseph S <jks(at)selectacast(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Index non-usage problem in 8.2.9
Date: 2008-09-03 04:31:12
Message-ID: 12690.1220416272@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Joseph S <jks(at)selectacast(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Finneid 2008-09-03 09:42:49 Re: plpgsql returning resultset
Previous Message Joseph S 2008-09-03 04:10:14 Re: Index non-usage problem in 8.2.9