mysql is running fine on the website and through some profiling (via codeigniter), I noticed some queries running EXTREMELY slow, as in taking more than 30 seconds. 95% of the time it is the sessions table, and in some cases, it slowly SELECTS from another table.
Slow table is of type innoDB.
I'm unsure what the proper process is to fix it.
I've tried repairing the table, but that is as far as I've got. I dont really know what to do next.
Any ideas?
@Nico @Mark Byers
SELECT *
FROM `ast_sessions`
WHERE `session_id` = '636519144bc6194898fd5a1f9e5fbc1d'
AND `user_agent` = 'Mozilla/5.0 (Windows NT 6.1; WOW64)'
Create Table:
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)