sql - Force MySQL To Evaluate One Condition Before The Other -
what best way rewrite query:
select myfield myprefix.mytable myfield2 in (?) , get_lock(concat('action:',myfield3), 0) = 1 limit 1
myfield2
has index on it.
right now, mysql evaluates in
operation first (because knows there index on it), , pipelines get_lock
operation.
how can sure case, , not switch other way around across mysql upgrades/etc.
aka, question is, how can make sure get_lock
never evaluated first. keep in 1 query.
it depends on kind of optimizer database using.
does order of clauses matter in sql
i not sure below solution optimized way if want 'get_lock' executed after checking 'myfield2' can try this:
select t.myfield (select * myprefix.mytable myfield2 in (?) ) t get_lock(concat('action:',t.myfield3), 0) = 1 limit 1
Comments
Post a Comment