to explain query below, should know have 3 variables current user used in query...
$radius
preference user wants search in
$lat
user's latitude
$lon
user's longitude
the relevant columns in zipdata table zipcode
lon
, lat
i have query works fine report other users within desired radius...
$query=" select username zipdata,seekers (pow((69.1*(lon-\"$lon\")*cos($lat/57.3)),\"2\")+pow((69.1*(lat-\"$lat\")),\"2\"))<($radius*$radius) , replace(seekers.postal,' ','') = zipdata.zipcode; ";
i have query returns specific users meeting criteria...
$query=" select * ( select a.username, match(a.highlight) against (\"{$keywords}\" in boolean mode) score resume_highlights join seekers on a.username = seekers.username , seekers.resume_status = 1 having score>0 union select b.username, match(b.skill,b.skill_list) against (\"{$keywords}\" in boolean mode) score resume_skills b join seekers on b.username = seekers.username , seekers.resume_status = 1 having score>0 union select c.username, match(c.education_title,c.education_organization) against (\"{$keywords}\" in boolean mode) score resume_education c join seekers on c.username = seekers.username , seekers.resume_status = 1 having score>0 union select d.username, match(d.employer_title,d.employer_organization) against (\"{$keywords}\" in boolean mode) score resume_employer d join seekers on d.username = seekers.username , seekers.resume_status = 1 having score>0 union select e.username, match(e.volunteer_title,e.volunteer_organization) against (\"{$keywords}\" in boolean mode) score resume_volunteer e join seekers on e.username = seekers.username , seekers.resume_status = 1 having score>0 ) x order score desc ";
both queries work independently; however, every attempt have made combine them 1 query has resulted in slow execution time.
update
i have indexes on seekers.postal
zipdata.lon
, zipdata.lat
. have assumed trick didn't. might built query bad see how 2 queries should combined.
i think link has answer:
the best way improve performance of select operations create indexes on 1 or more of columns tested in query. index entries act pointers table rows, allowing query determine rows match condition in clause, , retrieve other column values rows. mysql data types can indexed.
Comments
Post a Comment