H
H
Hint2013-01-23 13:48:40
MySQL
Hint, 2013-01-23 13:48:40

WHERE str LIKE 'a%' SORT BY LENGTH(str) LIMIT N?

Is it possible to optimize the selection WHERE str LIKE 'a%' ORDER BY LENGTH(str) LIMIT N? Or will it always be FULL SCAN?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Melkij, 2013-01-23
@Hint

like 'const%' can use an index by field.

E
eugene_t, 2013-01-23
@eugene_t

if this same limit limits the selection severely enough, why not do select… from (select… from… order by length(str) limit N) where str line '%a'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question