Mysql存储过程比直接查询花费更多时间:
我正在使用mysql 5.7 AWS RDS。我已经从存储过程中执行了查询,但是要花10秒钟,如果我直接执行相同的查询,则要花3.5秒钟。
两个查询的执行计划相同。
请帮助。
(来自评论)
SELECT state, state_code, country,
COUNT(DISTINCT a.user_id) users,
fn_score(SUM(sh),SUM(sh)+SUM(sn),SUM(uh),SUM(uh)+SUM(un),
SUM(bh),SUM(bh)+SUM(bn),SUM(rh),SUM(rh)+SUM(rn),SUM(mad/60),
IFNULL(SUM(a.tt),0),
IFNULL(SUM(a.tpd),0),0.10,0,
IFNULL(SUM(b.os),0),0.15) AS score
FROM ut AS a
INNER JOIN uts AS b ON a.user_id = b.user_id
AND a.tp_id = b.tp_id
INNER JOIN ur u ON a.user_id= u.id
GROUP BY state,state_code,country;