mysql - Like best performance in nested query -
i have principal requet 2 requets in. have problem in second nested query, have condition on id
, if made request id = 10
takes long time execute, if replace id 10
request execute in 1 second.
here request:
select sql_no_cache contact_groupe.id_contact_groupe toto.contact_groupe left join toto.`contact` `contact` on ((toto.contact_groupe.id_contact_groupe = toto.contact.id_contact_groupe)) left join toto.`project` `project` on ((toto.contact_groupe.id_contact_groupe = toto.project.id_contact_groupe) , ( toto.project.id_project in ( select max(toto.project.id_project) toto.project ( toto.contact_groupe.id_contact_groupe = toto.project.id_contact_groupe ) ) )) left join toto.`phase` `phase` on ((project.id_phase = toto.phase.id_phase)) left join sql_base.`user` `user_suivi` on ((toto.contact_groupe.id_user_suivi = user_suivi.id_user)) ( en_attente = '0' , contact_groupe.id_contact_groupe in ( select distinct(contact_groupe.id_contact_groupe) toto.contact_groupe left join toto.`contact` `contact` on ((toto.contact_groupe.id_contact_groupe = toto.contact.id_contact_groupe) left join toto.`source_contact_groupe` `source_contact_groupe` on ((toto.contact_groupe.id_contact_groupe = toto.source_contact_groupe.id_contact_groupe)) left join toto.`project` `project` on ((toto.contact_groupe.id_contact_groupe = toto.project.id_contact_groupe)) left join toto.`remarque` `remarque` on ((toto.contact_groupe.id_contact_groupe = toto.remarque.id_contact_groupe)) left join toto.`project_type_construction_options` `project_type_construction_options` on ((project.id_project = toto.project_type_construction_options.id_project)) left join toto.`project_concurrent` `project_concurrent` on ((project.id_project = toto.project_concurrent.id_project)) left join toto.`telephone` `telephone` on ((contact.id_contact = toto.telephone.id_contact)) ( en_attente = '0' , ( toto.project.id_project = '10' ) , toto.contact_groupe.id_entreprise = '2' ) ) , toto.contact_groupe.id_entreprise = '2' ) order toto.contact_groupe.id_contact_groupe asc
the line following problem toto.project.id_project = '10'
, don't understand why time execute request different between =
, like
let's start subquery. 17 lines you've written functionally identical this, why not use instead?
select distinct g.id_contact_groupe contact_groupe g join project p on p.id_contact_groupe = g.id_contact_groupe g.en_attente = 0 , p.id_project = 10 , g.id_entreprise = 2
Comments
Post a Comment