Inny sposób na przepisanie tego zapytania.
Grupuj i licz w każdym stole osobno, a następnie dołącz:
SELECT a.id,
COALESCE(b.t1, 0) AS t1,
COALESCE(c.t2, 0) AS t2,
COALESCE(d.t3, 0) AS t3
FROM
entity a
LEFT JOIN
( SELECT ei,
COUNT(*) AS t1
FROM table1
GROUP BY ei
) AS b
ON a.id = b.ei
LEFT JOIN
( SELECT ei,
COUNT(*) AS t2
FROM table2
GROUP BY ei
) AS c
ON a.id = c.ei
LEFT JOIN
( SELECT ei,
COUNT(*) AS t3
FROM table3
GROUP BY ei
) AS d
ON a.id = d.ei
;
Zdecydowanie powinieneś dodać indeks na (ei)
na każdym z 3 stołów, jeśli nie masz jednego.