Avoid functions on index columns

Applying a function to a key column will prevent the >DBMS from being able to search the index using the column value. For example, given these two queries to retrieve a particular row:

select * from t where keycol = :hostvar;
select * from t where rtrim(keycol) = :hostvar;

The first query can use the index to find the row very quickly. For the second query, the database must retrieve every value of the key column from either the table or the index, in order to apply the function to those values.

If possible, move the function to the other side of the expression:

select * from t where keycol = rpad(:hostvar, n);

Next: Function Indexes 

Home > Computers > Databases > Tuning > Functions > Functions

Viewing mobile website page. Switch to WML or Full HTML