1
J'utilise django sur webfaction, et j'ai un message "requête MySql prend trop de temps", sql estrequête MySql trop long - django sur webfaction
SELECT (1) AS `a` FROM `main_userprofile` WHERE `main_userprofile`.`id` = 98
C'est un sql assez simple , pourquoi la requête est-elle trop longue?
ici il est le 'create table':
main_userprofile | CREATE TABLE `main_userprofile` ( `id` int(11) NOT NULL auto_increment, `user_id` int(11) NOT NULL, `sex` smallint(6) NOT NULL, `active_number` varchar(64) NOT NULL, `phone_number` varchar(32) NOT NULL, `work_number` varchar(32) NOT NULL, ... ... PRIMARY KEY (`id`), UNIQUE KEY `user_id` (`user_id`) ) ENGINE=MyISAM AUTO_INCREMENT=1652 DEFAULT CHARSET=utf8 |
l'id est la clé primaire
l'expliquer:
explain SELECT (1) AS `a` FROM `main_userprofile` WHERE `main_userprofile`.`id` = 98; +----+-------------+------------------+-------+---------------+---------+---------+-------+------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+------------------+-------+---------------+---------+---------+-------+------+-------------+ | 1 | SIMPLE | main_userprofile | const | PRIMARY | PRIMARY | 4 | const | 1 | Using index | +----+-------------+------------------+-------+---------------+---------+---------+-------+------+-------------+
Que vous dit EXPLAIN PLAN lorsque vous exécutez la requête? –
essayer de vérifier la table avec mysqlcheck (http://dev.mysql.com/doc/refman/5.0/en/mysqlcheck.html) – newtover