mysql在网站上正常运行并通过一些分析(通过codeigniter),我注意到一些查询运行得很慢,比如超过30秒。 95%的时间是会话表,在某些情况下,它会慢慢从另一个表中选择。
慢速表的类型为innoDB。
我不确定修复它的正确过程是什么。
我试过修理桌子,但就我而言。我真的不知道接下来该做什么。
有什么想法吗?
@Nico @Mark Byers
SELECT *
FROM `ast_sessions`
WHERE `session_id` = '636519144bc6194898fd5a1f9e5fbc1d'
AND `user_agent` = 'Mozilla/5.0 (Windows NT 6.1; WOW64)'
创建表:
CREATE TABLE `ast_sessions` (
`session_id` varchar(40) COLLATE utf8_bin NOT NULL DEFAULT '0',
`ip_address` varchar(16) COLLATE utf8_bin NOT NULL DEFAULT '0',
`user_agent` varchar(150) COLLATE utf8_bin NOT NULL,
`last_activity` int(10) unsigned NOT NULL DEFAULT '0',
`user_data` text COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`session_id`,`user_agent`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
EXPLAIN SELECT:
+----+-------------+-------+------+---------------+------+---------+------+------+----- ------------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------+---------------+------+---------+------+------+----- ------------------------------------------------+
| 1 | SIMPLE | NULL | NULL | NULL | NULL | NULL | NULL | NULL | Impossible WHERE noticed after reading const tables |
+----+-------------+-------+------+---------------+------+---------+------+------+-----------------------------------------------------+
1 row in set (1 min 10.41 sec)