MySQL Query Tuning - Why is using a value from a variable so much slower than using a literal?
问题 UPDATE: I've answered this myself below. I'm trying to fix a performance issue in a MySQL query. What I think I'm seeing, is that assigning the result of a function to a variable, and then running a SELECT with a compare against that variable is relatively slow. If for testings sake however, I replace the compare to the variable with a compare to the string literal equivalent of what I know that function will return (for a given scenario), then the query runs much faster. For example: ... SET