Re: index not used in ( varchar = text ) - Mailing list pgsql-admin

From Tom Lane
Subject Re: index not used in ( varchar = text )
Date
Msg-id 20971.1046051478@sss.pgh.pa.us
Whole thread Raw
In response to Re: index not used in ( varchar = text )  ("Gaetano Mendola" <mendola@bigfoot.com>)
List pgsql-admin
"Gaetano Mendola" <mendola@bigfoot.com> writes:
>> Why would you want to cast that to text, if your field is a varchar?

> Of course that example was a semplification of a real
> situation:
> ..........
> my_login ALIAS FOR $1;

> SELECT *
> FROM user_login
> WHERE login = my_login;

> and $1 is of type TEXT.

So declare it as VARCHAR.  Or cast it to varchar.  You need to get rid
of the datatype ambiguity.  "text = text" is a different operator from
"varchar = varchar".

            regards, tom lane

pgsql-admin by date:

Previous
From: "Gaetano Mendola"
Date:
Subject: Re: index not used in ( varchar = text )
Next
From:
Date:
Subject: Re: \d tablename with psql over slow links...