J'ai une "requête lente" et n'a pas trouvé le "bon" index pour éviter la requête lente.requête lente mysql n'a pas trouvé le bon index
La requête est:
SELECT c.uid FROM tx_gwcalendar_competition c,tx_gestionprofildb_discipline d WHERE c.hidden=0 and c.deleted=0 and c.discipline=d.uid and d.usergroup=19 LIMIT 1;
et mes tables sont:
CREATE TABLE IF NOT EXISTS `tx_gwcalendar_competition` (
`uid` int(11) NOT NULL AUTO_INCREMENT,
`pid` int(11) NOT NULL DEFAULT '0',
`tstamp` int(11) NOT NULL DEFAULT '0',
`crdate` int(11) NOT NULL DEFAULT '0',
`cruser_id` int(11) NOT NULL DEFAULT '0',
`sys_language_uid` int(11) NOT NULL DEFAULT '0',
`l10n_parent` int(11) NOT NULL DEFAULT '0',
`l10n_diffsource` mediumtext,
`deleted` tinyint(4) NOT NULL DEFAULT '0',
`hidden` tinyint(4) NOT NULL DEFAULT '0',
`title` tinytext,
`discipline` int(11) NOT NULL DEFAULT '0',
`dept` tinytext,
`ville` tinytext,
`distance` tinytext,
`date` int(11) NOT NULL DEFAULT '0',
`description` text,
PRIMARY KEY (`uid`),
KEY `parent` (`pid`),
KEY `deleted` (`deleted`,`hidden`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=8659 ;
et
CREATE TABLE IF NOT EXISTS `tx_gestionprofildb_discipline` (
`uid` int(11) NOT NULL AUTO_INCREMENT,
`pid` int(11) NOT NULL DEFAULT '0',
`tstamp` int(11) NOT NULL DEFAULT '0',
`crdate` int(11) NOT NULL DEFAULT '0',
`cruser_id` int(11) NOT NULL DEFAULT '0',
`deleted` tinyint(4) NOT NULL DEFAULT '0',
`hidden` tinyint(4) NOT NULL DEFAULT '0',
`libelle` tinytext,
`description` text,
`usergroup` int(11) NOT NULL DEFAULT '0',
`sportup_tag` tinytext,
`form_mutation` text,
`documents` text,
`mutation` tinyint(3) NOT NULL DEFAULT '0',
`nolicence` tinyint(3) NOT NULL DEFAULT '0',
`agendahtml` text,
`objectifhtml` text,
`havestat` tinyint(3) NOT NULL DEFAULT '0',
`description_conseil` text,
`frais_admin` tinytext,
PRIMARY KEY (`uid`),
KEY `parent` (`pid`),
KEY `deleted_hidden_libelle` (`deleted`,`hidden`,`libelle`(20))
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=53 ;
Quand je lance une expliquer que je suis arrivé que:
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE c ALL deleted NULL NULL NULL 8658 Using where
1 SIMPLE d eq_ref PRIMARY PRIMARY 4 tbs888dbnew.c.discipline 1 Using where
J'essaie de mettre un index sur delete/hidden, mais maintenant je change encore avec 8658 key_len pour la première ligne, comme si je n'ai pas mis d'index ... mes connaissances dans mysql sont limitées, donc je n'ai pas savoir quoi faire (et si c'est possible ...). Donc, si quelqu'un a un conseil, n'hésitez pas.
Merci beaucoup
J'essaie juste, mais rien changer ... stil le même résultat. Merci – Mitchum
@Mitchum Voir mon édition – Eran
Salut, j'essaie d'ajouter la clé de la discipline, mais rien ne change ... Je suis perdu. Merci – Mitchum