Profil supprimé | Bonjour à tous,
Je vous solicite, dieux du SQL, ou pas, pour m'aider à optimiser, une méga requête XXL... J'ai essayé mais sans grand résultats....
Toute aide est la bien venu bien entendus... JE sèche vraiment la dessus, et en production ça commence à geuler car c'est trop long ( 1h30min d'attente pour exporter un rapport .csv ) et je les comprend... Le petit problème c'est que je suis arrivé il y a 6 mois... et que le SQL je le connais a peine aussi depuis 6 mois... et je dois bosser sur cette requette qui met trop de temps à être executé... Pour un Petit projet, la Base met 6 secondes à me sortir 29lignes... c'est déja beaucoup trop...
HELPPPPP Immense merci d'avance !
Code :
- SELECT
- out_miss_numero,
- out_miss_id,
- out_miss_proj,
- out_proj_numero,
- out_sous_projet_id,
- out_sous_projet_name,
- out_cand_consult,
- out_cand_bu,
- bcg_civ_lib,
- out_cand_id,
- out_cand_nom,
- out_cand_prenom,
- out_cand_imat,
- out_cand_typo,
- out_cand_dte_naiss,
- cp_codpos,
- cp_ville,
- out_ref_offre_stat_lib,
- OUT_EXP_PRO.epr_titre AS epr_titre1,
- ROME1.bcg_rome_code AS bcg_rome_code1,
- ROME1.bcg_rome_lib AS bcg_rome_lib1,
- cand_educ_lib,
- cand_educ_comment,
- cand_educ_date,
- out_cand_key_words,
- out_ref_situ_lib,
- out_cand_cong_deb,
- out_cand_cong_fin,
- out_cand_dte_in,
- out_cand_dte_activ,
- out_cand_dte_parm,
- out_cand_dte_anc,
- out_cand_dte_out,
- out_cand_dte_out_prev,
- out_ref_type_proj_lib,
- out_cand_prod_site_id,
- out_cand_bureau,
- out_cand_num_bureau,
- out_cand_poste_actu,
- out_cand_date_benef,
- out_cand_club_com,
- out_gpec_intitule,
- out_gpec_dte_deb,
- out_gpec_dte_fin,
- out_recl_type_lib,
- out_recl_date,
- out_ref_offre_contrat_lib,
- out_recl_date_fin,
- out_recl_contrat_nb_mois,
- out_recl_soc,
- out_recl_soc_ville,
- out_recl_soc_zip,
- ROME2.bcg_rome_code AS bcg_rome_code2,
- ROME2.bcg_rome_lib AS bcg_rome_lib2,
- ROME3.bcg_rome_code AS bcg_rome_code3,
- ROME3.bcg_rome_lib AS bcg_rome_lib3,
- out_activ_date,
- OUT_VOE_PRO.epr_titre AS epr_titre2,
- CLIENT.client_nom,
- CLIENT.client_adr3,
- out_typo_libelle,
- out_ref_activ_r_lib,
- out_activ_com,
- (SELECT out_activ_date FROM OUT_ACTIV WHERE out_activ_cand_id = out_cand_id AND out_activ_type='204 ' AND out_activ_result='2' ORDER BY out_activ_date DESC LIMIT 1) AS date_eeo,
- (SELECT out_activ_date FROM OUT_ACTIV WHERE out_activ_cand_id = out_cand_id AND out_activ_type='37 ' AND out_activ_result='2' ORDER BY out_activ_date DESC LIMIT 1) AS date_valid,
- (SELECT out_activ_date FROM OUT_ACTIV WHERE out_activ_cand_id = out_cand_id AND out_activ_result='2' ORDER BY out_activ_date ASC LIMIT 1) AS premier_entret,
- (SELECT out_activ_date FROM OUT_ACTIV WHERE out_activ_cand_id = out_cand_id AND out_activ_result='2' ORDER BY out_activ_date DESC LIMIT 1) AS dernier_entret,
- (SELECT COUNT(out_activ_id) FROM OUT_ACTIV WHERE out_activ_cand_id = out_cand_id AND (out_activ_type IN(1,3,5) OR out_activ_type BETWEEN '20' AND '37' OR out_activ_type BETWEEN '200' AND '299')AND out_activ_result='2') AS nb_entret,
- (SELECT COUNT(out_activ_id) FROM OUT_ACTIV WHERE out_activ_cand_id = out_cand_id AND (out_activ_type IN(1,2,4,38) OR out_activ_type BETWEEN '6' AND '16' OR out_activ_type BETWEEN '80' AND '100')AND out_activ_result='2') AS nb_atel,
- (SELECT COUNT(out_ove_id) FROM OUT_OVE WHERE out_ove_cand = out_cand_id) AS nb_pos,
- (SELECT COUNT(out_res_id) FROM OUT_RES_NEW WHERE out_res_cand_id = out_cand_id) AS nb_pos_res,
- (SELECT COUNT(out_ove_histo_id) FROM OUT_OVE_HISTO, OUT_OVE, OUT_OVE_TYPE WHERE out_ove_cand = out_cand_id AND out_ove_histo_ove_id = out_ove_id AND out_ove_histo_type = out_ove_type_id AND out_ove_histo_type='4') AS nb_entret_recrut,
- (SELECT COUNT(out_ove_histo_id) FROM OUT_OVE_HISTO, OUT_OVE WHERE out_ove_cand = out_cand_id AND out_ove_histo_ove_id = out_ove_id AND out_ove_histo_valid='1') AS nb_ove
-
- FROM OUT_CAND
- LEFT JOIN OUT_MISS ON out_cand_miss_id = out_miss_id
- LEFT JOIN BCG_CIV ON out_cand_civ = bcg_civ_id
- LEFT JOIN BCG_POST ON out_cand_city_id = bcg_post_id
- LEFT JOIN OUT_REF_OFFRE_STATUT ON out_cand_college = out_ref_offre_stat_id
- LEFT JOIN OUT_EXP_PRO ON out_cand_id = OUT_EXP_PRO.epr_cand_id AND OUT_EXP_PRO.epr_id = (SELECT OUT_EXP_PRO.epr_id FROM OUT_EXP_PRO WHERE OUT_EXP_PRO.epr_cand_id = out_cand_id ORDER BY OUT_EXP_PRO.epr_to DESC LIMIT 1)
- LEFT JOIN BCG_ROME ROME1 ON OUT_EXP_PRO.epr_rome = ROME1.bcg_rome_id
- LEFT JOIN OUT_CAND_EDUC ON out_cand_id = cand_educ_cand_id AND cand_educ_id = (SELECT cand_educ_id FROM OUT_CAND_EDUC WHERE cand_educ_cand_id = out_cand_id ORDER BY cand_educ_date DESC LIMIT 1)
- LEFT JOIN OUT_REF_SITU ON out_cand_situ_id = out_ref_situ_id
- LEFT JOIN OUT_REF_TYPE_PROJ ON out_cand_perso = out_ref_type_proj_id
- LEFT JOIN OUT_GPEC ON out_cand_id = out_gpec_cand_id AND out_gpec_id = (SELECT out_gpec_id FROM OUT_GPEC WHERE out_cand_id = out_gpec_cand_id ORDER BY out_gpec_dte_deb DESC LIMIT 1)
- LEFT JOIN OUT_RECL ON out_cand_id = out_recl_cand_id AND out_recl_id = (SELECT out_recl_id FROM OUT_RECL WHERE out_recl_cand_id = out_cand_id ORDER BY out_recl_date DESC LIMIT 1)
- LEFT JOIN OUT_RECL_TYPE ON OUT_RECL.out_recl_type_id = OUT_RECL_TYPE.out_recl_type_id
- LEFT JOIN OUT_REF_OFFRE_CONTRAT ON out_recl_contrat_id = out_ref_offre_contrat_id
- LEFT JOIN BCG_ROME ROME2 ON out_recl_rome_id = ROME2.bcg_rome_id
- LEFT JOIN OUT_ACTIV ON out_cand_id = out_activ_cand_id AND out_activ_type = '306' AND out_activ_id = (SELECT out_activ_id FROM OUT_ACTIV WHERE out_activ_type = '306' AND out_cand_id = out_activ_cand_id ORDER BY out_activ_date DESC LIMIT 1)
- LEFT JOIN OUT_PROJ ON out_proj_id = out_miss_proj
- LEFT JOIN OUT_SOUS_PROJET ON out_sous_projet_projet_id = out_proj_id
- LEFT JOIN OUT_VOE_PRO ON out_cand_id = OUT_VOE_PRO.epr_cand_id AND OUT_VOE_PRO.epr_id = (SELECT OUT_VOE_PRO.epr_id FROM OUT_VOE_PRO WHERE OUT_VOE_PRO.epr_cand_id = out_cand_id ORDER BY OUT_VOE_PRO.epr_scope ASC LIMIT 1)
- LEFT JOIN BCG_ROME ROME3 ON OUT_VOE_PRO.epr_rome = ROME3.bcg_rome_id
- LEFT JOIN CLIENT ON OUT_CAND.out_cand_prod_site_id = CLIENT.client_id
- LEFT JOIN OUT_TYPO ON OUT_CAND.out_cand_typo = out_typo_num AND out_cand_miss_id = out_typo_miss_id
- LEFT JOIN OUT_REF_ACTIV_RESULT ON out_ref_activ_r_id = out_activ_result
- WHERE out_miss_id = out_miss_id
- AND OUT_MISS.out_miss_proj = '609'
- AND OUT_MISS.out_miss_sous_projet_id = OUT_SOUS_PROJET.out_sous_projet_id
- ORDER BY out_cand_nom, out_cand_prenom
|
Message édité par Profil supprimé le 15-05-2012 à 16:20:37
|