Hello everyone, help me figure it out ..
Hoster complained "Abnormal load on the database server" to a large load in the code:
function searchTutor($param1 = '', $param2 = '', $param3 = '') { //echo "Under Construction";die(); $this->data['search_data'] = array(); $query_tail = " GROUP BY u.id ORDER BY u.is_premium = 1"; $condition_location = " AND 1=1 "; $condition_subject = " AND 1=1 "; $condition_experience = " AND 1=1 "; $condition_tutor_type = " AND 1=1 "; /** * * Common Query * with all condition predefined * */ $query = " SELECT u.*, ts.subject_id, s.subject_name, l.location_name, (SELECT pl.location_name FROM ".$this->db->dbprefix( 'locations' )." pl WHERE pl.id = l.parent_location_id ) AS parent_location_name, tt.tutor_type FROM dt_users u, dt_tutor_subjects ts, dt_tutor_locations tl, dt_subjects s, dt_locations l, dt_tutor_types tt, dt_tutor_selected_types tst, dt_users_groups ug WHERE ug.group_id = 3 AND u.active = 1 AND ts.subject_id = s.id AND u.location_id = l.id AND u.id = ug.user_id AND tt.tutor_type_id = tst.tutor_type_id "; Maybe somewhere to remove or add something? Give advice where to dig .. Thanks in advance!
EXPLAINyour request and see what it spends the most time. And rewrite your query usingJOIN. Looks better and theWHEREdoes not litter - ArchDemon