向查询添加其他联接时出现问题。
这个查询几乎要花一整分钟的时间来运行:
SELECT * FROM jos_mls AS mls
INNER JOIN jos_activeagents AS active ON mls.MSTLISTBRD = active.AGENTUID
INNER JOIN jos_agents AS agents ON active.AGENTUID = agents.AGTBRDIDMM
INNER JOIN jos_clstmp AS cl ON mls.MSTMLSNO = cl.MSTMLSNO
WHERE mls.MSTACTSTA != 'Inactive'
AND mls.MSTLISTDT >= SUBDATE(CURDATE(), INTERVAL 1 DAY)
如果我省略行
INNER JOIN jos_clstmp AS cl ON mls.MSTMLSNO = cl.MSTMLSNO
,则它花费的时间不到一秒钟。jos_clstmp表只有两列。一个键和一个时间戳。我不认为这会给流程增加太多,但是却扼杀了它。
最佳答案
INNER JOIN jos_clstmp AS cl ON mls.MSTMLSNO = cl.MSTMLSNO
两列都做
mls.MSTMLSNO and cl.MSTMLSNO
有钥匙/索引?
关于mysql - 添加第3个INNER JOIN后,MySQL查询花费的时间更长,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16722588/