当我在SQL语句WHERE类中使用“ 12345”之类的文字时,SQL语句执行时间为0.019秒,但是当我使用IN参数时,相同的UDP消耗4.19秒

CREATE DEFINER = `root`@`localhost` PROCEDURE `test_PFM`(IP_param  VARCHAR(6))
    BEGIN
    /*
    test query speed
    purpose:
    Use compare query out pu

    Bug:
     UDP takes 4 seconds when
    locojourney.LocoNumber = IP_param

    where as if locojourney.LocoNumber = '11516'
    executes at 0.019 second

    */

    DECLARE Output VARCHAR(1) ;

    SELECT locojourney.IShoc
    INTO Output
    FROM locojourney
    WHERE
    locojourney.JourneySerla = (
    SELECT MAX(locojourney.JourneySerla) FROM locojourney
    WHERE locojourney.LocoNumber = '11516') LIMIT 1;

    SELECT Output;


    END;

最佳答案

我衷心感谢Raymond先生和DRapp先生为我指明了正确的方向,实际上我是在将字符串编入smallint领域。
请标记线程为已解决。

关于mysql - MySQL存储过程使用参数变量消耗1:8倍,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55559503/

10-08 20:47