cast affects use of indexes ?

Started by Alex Vinogradovsover 17 years ago2 messagesgeneral
Jump to latest
#1Alex Vinogradovs
AVinogradovs@Clearpathnet.com

Guys,

I've got a table with an indexed column of a numeric user
type (implemented in C). When I run a select on that table
in a form of :

select * from sometable where column = 89464;

sequential scan is used...

When I rewrite the query to use cast like this :

select * from sometable where column = 89464::mytype;

bitmap index scan and bitmap heap scan are used.

Is it possible to make it work properly without
use of explicit casts ? Thanks!

Best regards,
Alex Vinogradovs

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Alex Vinogradovs (#1)
Re: cast affects use of indexes ?

Alex Vinogradovs <AVinogradovs@clearpathnet.com> writes:

Is it possible to make it work properly without
use of explicit casts ? Thanks!

Read
http://www.postgresql.org/docs/8.3/static/xindex.html
particularly the discussion of cross-type index operators.

regards, tom lane