Bonjour à tous,

Je souhaite vous faire part d'un problème que je rencontre lors de l'exécution d'une requête.

Cette requête me génère des temps de réponses assez longues (+ de 10 sec), or mes différentes tables ne comptent pas énormément de données.

Lorsque j'execute avec EXPLAIN la requete suivante, je constate que mes index (id_ann et xml_key) de la table PAGV5_annonces_images ne sont pas pris en compte.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
SELECT a.id_ann, a.id_reg, a.id_dep, a.id_cat, a.code_pos, a.ville, a.status, a.type, a.titre, a.ann, a.prix, a.date, o.urg, u.immediat, o.enc, i.nom AS nom_image, v.video
	FROM PAGV5_annonces a 
	LEFT JOIN PAGV5_annonces_options o ON a.id_ann = o.id_ann 
	LEFT JOIN PAGV5_annonces_video v ON a.id_ann = v.id_ann
	LEFT JOIN PAGV5_url u ON a.id_ann = u.id_ann
	LEFT JOIN PAGV5_annonces_images i ON (a.id_ann = i.id_ann OR a.xml_key = i.xml_key) AND i.id_ima = (SELECT MIN(id_ima) FROM PAGV5_annonces_images j WHERE j.id_ann = a.id_ann OR j.xml_key = a.xml_key)
	WHERE  etat = '2' AND a.id_dep IS NOT NULL AND a.code_pos IS NOT NULL AND type != 0 AND a.titre != '' AND a.ann != '' AND a.prix IS NOT NULL AND a.status != 0 GROUP BY u.id_ann ORDER BY a.date DESC LIMIT 0, 40;
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
id 	select_type 	table 	type 	possible_keys 	key 	key_len 	ref 	rows 	Extra
1 	PRIMARY 	o 	system 	PRIMARY 	NULL 	NULL 	NULL 	0 	const row not found
1 	PRIMARY 	v 	system 	id_ann 	NULL 	NULL 	NULL 	0 	const row not found
1 	PRIMARY 	a 	ref 	search_reg,search_type,search 	search_reg 	1 	const 	180857 	Using where; Using temporary; Using filesort
1 	PRIMARY 	u 	ref 	id_ann 	id_ann 	4 	jefouine.a.id_ann 	3 	 
1 	PRIMARY 	i 	eq_ref 	PRIMARY,id_ann,xml_key 	PRIMARY 	4 	func 	1 	 
2 	DEPENDENT SUBQUERY 	j 	ALL 	id_ann,xml_key 	NULL 	NULL 	NULL 	446030 	Using where
J'ai bien tenté l'utilisation de "USE INDEX" et "FORCE INDEX" sans succès.

Pouvez-vous m'indiquer ce qui cloche dans cette requête ?

Merci par avance.