Re: index used when casting to different type? - Mailing list pgsql-general

From Tom Lane
Subject Re: index used when casting to different type?
Date
Msg-id 10839.982637221@sss.pgh.pa.us
Whole thread Raw
In response to index used when casting to different type?  (adb <adb@Beast.COM>)
Responses Re: index used when casting to different type?
List pgsql-general
adb <adb@Beast.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

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Weird indices
Next
From: Stephan Szabo
Date:
Subject: Re: Weird indices