このクエリを書き直す別の方法。
各テーブルを個別にグループ化してカウントし、参加します:
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
;
(ei)
に必ずインデックスを追加する必要があります まだ持っていない場合は、3つのテーブルのそれぞれに。