http://www.perlmonks.org?node_id=414995


in reply to OT: Sql statemet (how to ignore lower-upper case)

And this still has absolutely nothing to do with Perl but I just have to say it again:
Watch out using functions like lower, upper or what not in WHERE clauses like:
select name from table where lower(name) = 'fubar'
Using a function in a where clause on a database column prevents the database from using any indexes. It has to apply the function to all rows first before it can decide about the selection and that's disastrous for performance if it is a big table.

pelagic

Replies are listed 'Best First'.
Re^2: OT: Sql statement (how to ignore lower-upper case)
by thor (Priest) on Dec 15, 2004 at 13:46 UTC
    I realize that your statement is true for most database engines, but Postgres has a nifty feature.

    thor

    Feel the white light, the light within
    Be your own disciple, fan the sparks of will
    For all of us waiting, your kingdom will come

      Interesting!
      Even Oracle got their Funcion Based Index. If you know in advance that you will be using something like that, it helps a lot!

      pelagic
        From reading the doc, it is of significant note that it's expensive to maintain that index, as it needs to be re-computed for every insert and update. It's not something to take lightly. However, it might make sense to do this on a relatively static database, or one in which the maintainence time is irrelevant, but access time is key.

        thor

        Feel the white light, the light within
        Be your own disciple, fan the sparks of will
        For all of us waiting, your kingdom will come