Bonjour,
J'ai une requête SQL à optimiser.
Ma question porte en particulier sur les clauses IN, NOT IN, et OR, AND.
Dans quelle mesure peut-on optimiser une requête avec ces clauses ?
<code>
SELECT DISTINCT
adhe_no_bull,
Cour_dat_eff,
Cour_nom_adhes,
cour_cod_prod,
cour_cod_part,
cour_cod_aven,
DOCUMENTS.*
FROM COURRIERS,
DOCUMENTS,
Adhesions
WHERE DOCU_CODE = COUR_COD_AVEN
AND DOCU_TYPE = COUR_COD_PROD
AND ADHE_NO_ADHES = COUR_NO_ADHES
AND COUR_COD_PROD = 72
AND COUR_COD_AVEN ='INIT'
AND adhe_dat_cpta IS NOT NULL
AND (
(adhe_flg_transfert=0)
OR (adhe_flg_transfert=1 AND adhe_cont_recep IS NOT NULL)
)
AND adhe_no_bull NOT IN
( SELECT distinct adhe_no_bull
FROM adhesions,
evenements
WHERE adhe_no_adhes = even_no_adhes
and adhe_cod_prod = even_cod_prod
AND adhe_cod_prod = 72
AND ( adhe_dat_cpta IS NULL
OR (adhe_flg_transfert = 1 AND adhe_cont_recep IS NULL)
OR even_dat_val IS NULL)
)
</code>