SELECT DISTINCT cl.client,cl.clientUNIQUE,(SELECT COUNT(taskUNIQUE)AS countTasks FROM tasks WHERE state ='NF'AND clientUNIQUE = cl.clientUNIQUE AND status ='V')AS ActiveTasks,(SELECT COUNT(projectUNIQUE) )FROM项目WHERE status ='V'AND state!='end'AND clientUNIQUE = cl.clientUNIQUE)AS ActiveProjects FROM clients AS cl LEFT JOIN tasks AS tsk ON cl.clientUNIQUE = tsk.clientUNIQUE WHERE cl.status ='V' AND cl.accountUNIQUE ='[client] 0E2D3B21D716BB71A83331558656EC47'Order by ActiveTasks DESC LIMIT 10
This query takes about 5 second to run. Too many counts? Any suggestion to improve performance?
答案 0 :(得分:0)
好的,这很尴尬,但我没有创建任何索引。感谢kmoser引导我找到答案的问题。