Can some one tell me the difference between INSTR and LIKE in Oracle?
Which one is faster in Oracle10g?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That depends on the data and on the pattern. If you use
like 'a%', then Oracle can use a BTree indexes to look up the matches because it can search the btree with the start of the pattern and then consider only the subtree.This doesn’t work for
LIKE '%a'but you can work around this by creating a calculated column which reverses all values from the column you want to search (so you get the pattern above).If you use hashed indexes, there is little that Oracle can do but scan the whole index. It might sill be faster when there are only few different values.
I’m not sure whether
INSTRcan ever use an index because it has no fixed anchor.So like with all performance questions: