Is substr or LIKE faster in Oracle?

后端 未结 6 1581
野的像风
野的像风 2020-12-24 12:30

Would

WHERE substr(my_field,1,6) = \'search\'

or

WHERE my_field LIKE \'search%\'

be faster in Oracle, o

6条回答
  •  再見小時候
    2020-12-24 13:00

    I would profile both. But I would guess the 'LIKE' would be much faster, because it uses the binary search on the index (if the field is indexed). If you use the SUBSTR method, you will end up with a full table scan, as Oracle has to process row by row the function.

提交回复
热议问题