I am trying to optimize my queries but when I try to add some indexes with this query:
ALTER TABLE `user` ADD INDEX `last_activity_date` (`last_activity_date`);
... it crashes my MySQL server. I mean that my websites are not responding anymore and my queries are not executed. The only solution I have is to restart MySQL. It's really annoying because I have an app with hundreds of users who obviously can't use it when it's crashed.
I have a MySQL log file but I don't see any error in it. In your opinion what can be the problem here? Could it be because some users are interacting with the DB while I'm adding indexes? I use InnoDB.
I have more than 100.000 records in the user table which looks like that :
CREATE TABLE `user` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`encrypt_id` varchar(255) DEFAULT NULL,
`register_date` datetime DEFAULT NULL,
`last_login_date` datetime DEFAULT NULL,
`username` varchar(255) DEFAULT NULL,
`password` varchar(255) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
`banned` int(11) DEFAULT NULL,
`banned_reason` text,
`first_step_form` int(11) DEFAULT '0',
`status` int(11) DEFAULT NULL,
`referer` varchar(255) DEFAULT NULL,
`rank` int(11) DEFAULT NULL,
`fb_id` bigint(20) DEFAULT NULL,
`last_activity_date` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `last_activity_date` (`last_activity_date`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1