0
我的表xm_c是這樣創建的:
選擇:MySQL的全文索引用於MATCH()AGAINST但不適用於=
CREATE TABLE `xm_c` ( `category_id` char(16) NOT NULL default '', `label` char(64) NOT NULL default '', `flags` smallint(5) unsigned default NULL, `d0` date default NULL, `d1` date default NULL, `ct` int(6) unsigned default NULL, `t_update` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, PRIMARY KEY (`category_id`), **FULLTEXT KEY `label` (`label`)** ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DELAY_KEY_WRITE=1;
全文索引在下面的查詢不使用* from xm_c where label ='TomCruise';
其中,因爲它是這裏使用:
SELECT * FROM xm_c其中MATCH(標籤)AGAINST( '湯姆·克魯斯');
mysql> explain select * from xm_c where MATCH(label) AGAINST('TomCruise'); > id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra **1 | SIMPLE | xm_c | fulltext | label | label | 0 | | 1 | Using where** mysql> explain select * from xm_c where label = 'TomCruise'; > id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra **1 | SIMPLE | xm_c | ALL | label | NULL | NULL | NULL | 5673360 | Using where**
有人能解釋一下嗎?不應該在這兩個查詢中使用INDEX?
使用FULLTEXT INDICES時是否存在語法約束?
謝謝您的回答。據我所知,索引是爲一列或一組列創建的,以實現更快的搜索。那麼相應列的索引不應該用於涉及該列的任何搜索? – raghu 2011-03-07 12:01:52