次のクエリの実行には永遠に時間がかかります。すべてのテーブルには、200,000を超えるレコードが含まれています。インデックスは、joiningステートメントのすべての列に存在します。
Select files.filename,
coalesce(temp_decmetadata.glare_roadGlare, 0) as glare_roadGlare,
coalesce(temp_decmetadata.glare_sun, 0) as glare_sun,
coalesce(temp_decmetadata.spray_heavySpray, 0) as spray_heavySpray,
coalesce(temp_kafaspdobjectdata.contrast_wellVisible, 0) as contrast_wellVisible,
coalesce(temp_kafaspdobjectdata.roadSafety_zebraCrossing, 0) as roadSafety_zebraCrossing,
coalesce(temp_visionmetadata.roadUser_bicycle, 0) as roadUser_bicycle,
coalesce(temp_visionmetadata.roadUser_car, 0) as roadUser_car,
coalesce(temp_visionmetadata.roadUser_pedestrian, 0) as roadUser_pedestrian
from files
left join
(
Select id,
count(case when glare like '%roadGlare%' then 1 end) as glare_roadGlare,
count(case when glare like '%sun%' then 1 end) as glare_sun,
count(case when spray like '%heavySpray%' then 1 end) as spray_heavySpray
from decmetadata
group by id
) temp_decmetadata on temp_decmetadata.id = files.id
left join
(
Select id,
count(case when contrast like '%wellVisible%' then 1 end) as contrast_wellVisible,
count(case when roadSafety like '%zebraCrossing%' then 1 end) as roadSafety_zebraCrossing
from kafaspdobjectdata
group by id
) temp_kafaspdobjectdata on temp_kafaspdobjectdata.id = files.id
left join
(
Select id,
count(case when roadUser like '%bicycle%' then 1 end) as roadUser_bicycle,
count(case when roadUser like '%car%' then 1 end) as roadUser_car,
count(case when roadUser like '%pedestrian%' then 1 end) as roadUser_pedestrian
from visionmetadata
group by id
) temp_visionmetadata on temp_visionmetadata.id = files.id
「ExplainSelect...」の結果は以下に添付されています。