mysql where not in to left outer join -
i have following query , convert using left outer join instead of not in see if run faster way. it's taking query 40 seconds run on our database. i'm not familiar enough using outer joins type of thing convert myself.
select c.contact_id contact_id, c.orgid organization_id, c.first_name first_name, c.last_name last_name, a.address_state state cnx_contact c inner join cnx_address on c.home_address_uid = a.address_uid a.address_state = 'oh' , (c.orgid = 45 or c.orgid = 55) , c.contact_id not in ( select pc.contact_id cnx_contact c inner join cnx_address on c.home_address_uid = a.address_uid inner join cnx_contact_group_participant gp on c.contact_id = gp.contact_id inner join cnx_contact_participant_role cr on gp.participant_role_uid = cr.participant_role_uid inner join cnx_contact_group cg on gp.group_uid = cg.group_uid inner join cnx_contact_group_participant pgp on cg.primary_participant_uid = pgp.participant_uid inner join cnx_contact pc on pgp.contact_id = pc.contact_id (c.orgid = 45 or c.orgid = 55) , cr.name = 'applicant' );
select c.columns cnx_contact c inner join cnx_address on c.home_address_uid = a.address_uid left join (subquery goes here) x on x.contact _id = c.contact_id a.participant_state = 'oh' , c.orgid in(45,55) , x.contact_id null;
Comments
Post a Comment