MySQL Query Tuning - Why is using a value from a variable so much slower than using a literal?

后端 未结 1 1470
南方客
南方客 2021-01-12 15:32

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 r

相关标签:
1条回答
  • 2021-01-12 16:15

    Was finished writing the question when the answer hit me, so posting anyway for knowledge sharing!

    I realised that the return value of the metaphone function was UTF8.

    The compare to a latin1 field was obviously incurring a fairly heavy performance overhead.

    I replaced the variable assignment with:

    SET @metaphone_val:= CONVERT(double_metaphone(p_parameter) USING latin1);
    

    Now the query runs as fast as I would expect.

    0 讨论(0)
提交回复
热议问题