Bon, j'ai tout converti en InnoDB et placé des foreign keys la où ca me semblait nécéssaire. À priori les pages sont passé de 1.1 sec à 0.4 pour le temps des requêtes.
Donc, voici donc les résultats:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 CREATE TEMPORARY TABLE sq SELECT msgid, `show` FROM he_fromto WHERE `show`!=0 AND persoid = 325 ORDER BY `msgid` DESC LIMIT 0,50; ##Traitement en 0.2341 sec.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 CREATE TEMPORARY TABLE sq SELECT msgid, `show` FROM he_fromto WHERE `show`!=0 AND persoid = 325 ORDER BY `msgid` DESC LIMIT 0,50; SELECT SQL_NO_CACHE he.msg, he.date, he.id AS hid, he.type, pc.nom, ft.fromto, ft.persoid, p.sexe, p.imgurl, ft.`show` FROM sq INNER JOIN he AS he ON ( he.id = sq.msgid ) INNER JOIN he_fromto AS ft ON ( ft.msgid = he.id ) LEFT JOIN perso_connu AS pc ON ( pc.persoid =325 AND pc.nomid = ft.persoid ) LEFT JOIN perso AS p ON ( p.id = ft.persoid ) ORDER BY he.`date` DESC , hid ASC , ft.fromto ASC , pc.nom ASC LIMIT 0 , 30 ##Traitement en 0.2361 sec.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 CREATE TEMPORARY TABLE sq SELECT msgid, `show` FROM he_fromto WHERE `show`!=0 AND persoid = 325 ORDER BY `msgid` DESC LIMIT 0,50; ALTER TABLE sq ADD INDEX(msgid); SELECT SQL_NO_CACHE he.msg, he.date, he.id AS hid, he.type, pc.nom, ft.fromto, ft.persoid, p.sexe, p.imgurl, ft.`show` FROM sq INNER JOIN he AS he ON ( he.id = sq.msgid ) INNER JOIN he_fromto AS ft ON ( ft.msgid = he.id ) LEFT JOIN perso_connu AS pc ON ( pc.persoid =325 AND pc.nomid = ft.persoid ) LEFT JOIN perso AS p ON ( p.id = ft.persoid ) ORDER BY he.`date` DESC , hid ASC , ft.fromto ASC , pc.nom ASC LIMIT 0 , 30 ##Traitement en 0.2046 sec.Explain sur la dernière requête (celle avec la sous-requête):
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 SELECT SQL_NO_CACHE he.msg, he.date, he.id AS hid, he.type, pc.nom, ft.fromto, ft.persoid, p.sexe, p.imgurl, ft.`show` FROM (SELECT SQL_NO_CACHE msgid, `show` FROM he_fromto WHERE `show`!=0 AND persoid = 325 ORDER BY `msgid` DESC LIMIT 0,50) as sq INNER JOIN he AS he ON ( he.id = sq.msgid ) INNER JOIN he_fromto AS ft ON ( ft.msgid = he.id ) LEFT JOIN perso_connu AS pc ON ( pc.persoid =325 AND pc.nomid = ft.persoid ) LEFT JOIN perso AS p ON ( p.id = ft.persoid ) ORDER BY he.`date` DESC , hid ASC , ft.fromto ASC , pc.nom ASC LIMIT 0 , 30 ##Traitement en 0.2613 sec.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 50 Using temporary; Using filesort 1 PRIMARY he eq_ref PRIMARY PRIMARY 4 sq.msgid 1 1 PRIMARY ft ref msgid msgid 4 he.id 1 Using where; Using index 1 PRIMARY pc ref persoid,nomid persoid 4 const 4 1 PRIMARY p eq_ref PRIMARY PRIMARY 4 ft.persoid 1 2 DERIVED cc_he_fromto index PRIMARY msgid 4 NULL 72933 Using where; Using index
Ceci étant dis, je ne suis pas en mesure d'avoir le temps requis pour le ALTER TABLE dans phpmyadmin, ou les temps totaux pour l'ensemble des requêtes. PHPMyadmin ne semble toujours donner les temps que pour les dernière requête.
Je ne peux pas non plus faire un EXPLAIN si j'utilise une table temporaire. (PMA retourne rien)
Partager