SELECT PatientID as 'PatientIDIX', claims.ClaimID as 'ClaimIDIX', ClaimThroughDate as 'ClaimThroughDateIX', HCPCCode, ProcedureID
FROM `t1`.revenue revenue
JOIN `t1`.patient patient ON revenue.ClaimID = patient.ClaimID
JOIN `t1`.claims claims ON claims.ClaimID = revenue.ClaimID
LEFT JOIN `t1`.procedures procedures ON procedures.ClaimID = revenue.ClaimID
WHERE HCPCCode IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)
OR ProcCode IN (11, 22, 33, 44, 55, 66, 77, 88, 99, 1010);


我想知道是否有人对为什么上面的查询花了这么长时间有所了解。我相信是因为左加入。谢谢!

最佳答案

我发现了几篇文章可能对您有所帮助:


http://explainextended.com/2009/08/18/passing-parameters-in-mysql-in-list-vs-temporary-table/


http://www.slideshare.net/techdude/how-to-kill-mysql-performance
MYSQL OR vs IN performance



根据您的数据,索引编制和其他因素,最简单的解决方案可能是使用临时表而不使用IN语句。

关于mysql - 谁能为我提供一些了解为什么此查询需要很长时间才能运行?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34225968/

10-11 05:05