Re: index used when casting to different type?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: adb <adb(at)Beast(dot)COM>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: index used when casting to different type?
Date: 2001-02-20 02:47:01
Message-ID: 10839.982637221@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

adb <adb(at)Beast(dot)COM> writes:
> If I have a table with a key column stored as text and
> another table with a key column stored as an int4 and
> I join the two by casting the in4 column to text, will the existing
> index on the int4 key be used?

Nope. Indexes are associated with a particular datatype and only work
for comparison operators of that datatype. The index on the first
table's text column could possibly be used in this scenario, but not
the one on the int4 column.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2001-02-20 02:50:35 Re: Weird indices
Previous Message Larry Rosenman 2001-02-20 02:34:47 Re: Re: Postgres slowdown on large table joins