MySQL Forums
Forum List  »  Newbie

EXPLAIN on SELECT is confusing me
Posted by: john flood
Date: March 17, 2009 07:22AM

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.

Options: ReplyQuote


Subject
Written By
Posted
EXPLAIN on SELECT is confusing me
March 17, 2009 07:22AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.