Categories
Database Development

MySQL using different index when direct index exist on columns

I have following table (stripped off other columns, indexes for simplicity) CREATE TABLE `issues` ( `id` int(11) NOT NULL AUTO_INCREMENT, `book_id` int(11) NOT NULL, `number` int(11) DEFAULT ‘0’, `title` varbinary(1024) DEFAULT NULL, `created_at` datetime DEFAULT NULL, `updated_at` datetime DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `index_issues_on_book_id_and_number` (`book_id`,`number`), KEY `index_issues_on_book_id_and_updated_at` (`book_id`,`updated_at`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 […]