我有一张大桌子,搜索经常发生在TEXT
字段(它不能是VARCHAR
)。这很慢;所以,我试着添加一个索引:
ALTER TABLE big_table ADD FULLTEXT INDEX `Index_name` (`NAME`);
然而,性能没有改变,仍然太慢。如何添加“好”索引? (如果它可能是唯一的,那将是一个加分)
这是表格的DDL:
CREATE TABLE `bigtable` (
`NAME` text NOT NULL,
`VALUE` varchar(255) NOT NULL DEFAULT '',
`DESCRIPTION` varchar(255) NOT NULL DEFAULT ''
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
和解释:
explain
UPDATE table
SET VALUE = VALUE + 1, DESCRIPTION = "whatever"
where name = "Total visits";
id, select_type, table, type, possible_keys, key, key_len, ref , rows, Extra
1, SIMPLE, table, ALL, null, null, null, null, 30592, Using Where
并在索引读取后:
id, select_type, table, type, possible_keys, key, key_len, ref , rows, Extra
1, SIMPLE, table, ALL, null, null, null, null, 30592, Using where