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

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -