J'ai besoin de votre aide pour optimiser la requête à évitez d'utiliser "Using filesort". Le travail de la requête est de sélectionner tous les articles qui appartiennent à tag spécifique. La requête est:Optimisation de la requête MySql pour éviter d'utiliser "Using filesort"
select title
from tag,
article
where tag = 'Riyad'
AND tag.article_id = article.id
order by tag.article_id
La structure des tables sont les suivantes:
table Tag
CREATE TABLE `tag` (
`tag` VARCHAR(30) NOT NULL ,
`article_id` INT NOT NULL ,
KEY `tag` (`tag`),
KEY `article_id` (`article_id`)
) ENGINE = MYISAM ;
Article Table
CREATE TABLE `article` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`title` VARCHAR(60) NOT NULL
) ENGINE = MYISAM
Données d'échantillons
INSERT INTO `article` VALUES (1, 'About Riyad');
INSERT INTO `article` VALUES (2, 'About Newyork');
INSERT INTO `article` VALUES (3, 'About Paris');
INSERT INTO `article` VALUES (4, 'About London');
INSERT INTO `tag` VALUES ('Riyad', 1);
INSERT INTO `tag` VALUES ('Saudia', 1);
INSERT INTO `tag` VALUES ('Newyork', 2);
INSERT INTO `tag` VALUES ('USA', 2);
INSERT INTO `tag` VALUES ('Paris', 3);
INSERT INTO `tag` VALUES ('France', 3);
Merci, ça marche! –