Hi,
I've got this query below;
EXPLAIN
SELECT EDPG_SchAttYearCode AS School_Year,
EDPG_SchAttTermCode AS School_Term,
COALESCE( lookup_pcodegeo.LKPC_District, 'Unknown' ) AS Geography,
EDPG_L0Code AS Ethnicity,
EDPG_Gender AS Gender,
COUNT( DISTINCT (EDPG_UPN) ) AS Total_Pupils
FROM EDPG_PupilGrouped
LEFT
JOIN
Lookup_PcodeGeo
ON
EDPG_Postcode = LKPC_Postcode
GROUP BY
School_Year,
School_Term,
LKPC_District,
Ethnicity,
Gender
When I run the EXPLAIN before the select I get the below
Rows: 2
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE EDPG_PupilGrouped ALL NULL NULL NULL NULL 243425 Using temporary; Using filesort
1 SIMPLE Lookup_PcodeGeo eq_ref PRIMARY PRIMARY 8 development.EDPG_PupilGrouped.EDPG_Postcode 1
even as a newbie I know that having ALL & NULL in the above is not good, (is it?)
I have indexes on the below
EDPG_SchAttYearCode
EDPG_SchAttTermCode
EDPG_UPN
any help would be great.
thanks.