Re: index scan with functional indexes

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: pg@fastcrypt.com
Cc: pgsql-hackers@postgresql.org
Date: 2004-01-27T17:33:01Z
Lists: pgsql-hackers
Dave Cramer <pg@fastcrypt.com> writes:
> create index r_url_idx on url( fn_strrev(url));

> explain select * from url where url like fn_strrev('%beta12.html');
>                        QUERY PLAN
> ---------------------------------------------------------
>  Seq Scan on url  (cost=0.00..13281.70 rows=1 width=454)
>    Filter: ((url)::text ~~ 'lmth.21ateb%'::text)

> Is it possible to get the planner to use an index scan ?

Sure, but not that way.  Try "fn_strrev(url) like something".
You have to compare the indexed value to something...

			regards, tom lane