> ircbot=> explain select nick,hostname,dttime,logtype from logins where
> nick=lower('anick') ORDER BY dttime desc;
> NOTICE: QUERY PLAN:
>
> Sort (cost=19913.31 size=0 width=0)
> -> Seq Scan on logins (cost=19913.31 size=42498 width=44)
> ---[ CUT ]---
>
> but when removing the lower(), it uses the index:
>
> ---[ CUT ]---
> ircbot=> explain select nick,hostname,dttime,logtype from logins where
> nick='anick' ORDER BY dttime desc;
>
> NOTICE: QUERY PLAN:
>
> Sort (cost=15.68 size=0 width=0)
> -> Index Scan using logins_nick_idx on logins (cost=15.68 size=214
> width=44)
> ---[ CUT ]---
>
> shouldn't the optimizer convert lower('anick') to lowercase first, then
> use that value in searching the logins_nick_idx index ?
>
> btw, this is using postgres 6.4.2 (system is a debian box, p2-350 with
> 256m, all uw scsi </brag> )
>
We have on our TODO list:
* Use index with constants on functions
Seems we have not implemented it yet. It may be done in 6.5, but I
don't think so.
-- Bruce Momjian | http://www.op.net/~candle maillist@candle.pha.pa.us | (610)
853-3000+ If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill,
Pennsylvania19026