in reply to Re^4: same query, different execution, different performance (substr)
in thread same query, different execution, different performance
Some databases have query optimizers that know how to use an index when told "LIKE 'blah%'".
I think most query optimizers will know to use an index on "LIKE 'blah%'", but not when the query plan is determined at prepare time (for those sorts of databases), and the query optimizer is told "LIKE ?" and only later is given the argument "blah%".
Some database have query optimizers that know how to use an index when told the equivalent thing using SUBSTR().
A quick test with Oracle (update: and Sybase, and from what I recall, Informix) seems to show that it doesn't know to use an index with SUBSTR, and some quick googling on Postgres seems to imply that a function based index would be required there also. I'm not saying there's no database smart enough to use a regular index on a column for a substring search, I just haven't seen it yet.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^6: same query, different execution, different performance (Pg's text_pattern_ops)
by erix (Prior) on Feb 14, 2012 at 21:00 UTC | |
by runrig (Abbot) on Feb 14, 2012 at 21:25 UTC | |
by erix (Prior) on Feb 14, 2012 at 21:47 UTC |