par
Invité » 20 janv. 2006, 17:42
Il y a 36 astuces pour optimiser une requête.
Tout dépend de celle-ci.
Je ne maitrise pas trop les index
SELECT pxphotos.id, pxphotos.phnom
FROM pxphotos , idxcategorie , idxepoque , idxkeywords
WHERE pxphotos.valider='yes'
AND pxphotos.id=idxcategorie.id_photo
AND idxcategorie.terme='notre présélection'
AND pxphotos.id=idxepoque.id_photo
AND idxepoque.terme='Moyen Age'
AND pxphotos.id=idxkeywords.id_photo
AND idxkeywords.terme='bâtiments civils'
ORDER BY pxphotos.id ;
AVEC
id PRIMARY KEY UNIQUE pour pxphotos , idxcategorie , idxepoque , idxkeywords
terme dans idxcategorie, idxepoque, idxkeywords = INDEX
et un EXPLAIN me donne:
table type possible_keys key key_len ref rows Extra
idxkeywords ref terme terme 41 const 537 where used; Using temporary; Using filesort
pxphotos eq_ref PRIMARY PRIMARY 4 idxkeywords.id_photo 1 where used
idxcategorie ALL terme NULL NULL NULL 7853 where used
idxepoque ALL terme NULL NULL NULL 8020 where used
Ce sont les ALL et NULL qui m'interpelle
[quote="albat"]Il y a 36 astuces pour optimiser une requête.
Tout dépend de celle-ci.[/quote]
Je ne maitrise pas trop les index
SELECT pxphotos.id, pxphotos.phnom
FROM pxphotos , idxcategorie , idxepoque , idxkeywords
WHERE pxphotos.valider='yes'
AND pxphotos.id=idxcategorie.id_photo
AND idxcategorie.terme='notre présélection'
AND pxphotos.id=idxepoque.id_photo
AND idxepoque.terme='Moyen Age'
AND pxphotos.id=idxkeywords.id_photo
AND idxkeywords.terme='bâtiments civils'
ORDER BY pxphotos.id ;
AVEC
id PRIMARY KEY UNIQUE pour pxphotos , idxcategorie , idxepoque , idxkeywords
terme dans idxcategorie, idxepoque, idxkeywords = INDEX
et un EXPLAIN me donne:
table type possible_keys key key_len ref rows Extra
idxkeywords ref terme terme 41 const 537 where used; Using temporary; Using filesort
pxphotos eq_ref PRIMARY PRIMARY 4 idxkeywords.id_photo 1 where used
idxcategorie ALL terme NULL NULL NULL 7853 where used
idxepoque ALL terme NULL NULL NULL 8020 where used
Ce sont les ALL et NULL qui m'interpelle