我现在正在编写一个包含超过20M记录的业务数据库的项目。 这是表结构:
CREATE TABLE IF NOT EXISTS `business` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`rdate` datetime NOT NULL,
`valid` int(1) NOT NULL,
`visible` int(1) NOT NULL,
`lockItem` int(1) NOT NULL,
`parent` int(10) NOT NULL,
`titleENG` varchar(254) COLLATE utf8_bin NOT NULL,
`address` varchar(254) COLLATE utf8_bin NOT NULL,
`city` varchar(254) COLLATE utf8_bin NOT NULL,
`state` varchar(254) COLLATE utf8_bin NOT NULL,
`zipCode` varchar(254) COLLATE utf8_bin NOT NULL,
`country` varchar(254) COLLATE utf8_bin NOT NULL,
`webAddress` varchar(254) COLLATE utf8_bin NOT NULL,
`phone` varchar(254) COLLATE utf8_bin NOT NULL,
`fax` varchar(254) COLLATE utf8_bin NOT NULL,
`contact_name` varchar(254) COLLATE utf8_bin NOT NULL,
`contact_title` varchar(254) COLLATE utf8_bin NOT NULL,
`contact_gender` enum('','male','female') COLLATE utf8_bin NOT NULL,
`company_employee` varchar(254) COLLATE utf8_bin NOT NULL,
`text` text COLLATE utf8_bin NOT NULL,
`bigPic` varchar(254) COLLATE utf8_bin NOT NULL,
`keywords` varchar(254) COLLATE utf8_bin NOT NULL,
`lowerTitle` varchar(256) COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`),
KEY `visible` (`visible`),
KEY `parent` (`parent`),
KEY `valid` (`valid`),
KEY `titleENG` (`titleENG`),
KEY `state` (`state`),
KEY `country` (`country`),
KEY `city` (`city`),
KEY `keywords` (`keywords`),
FULLTEXT KEY `titleENG_2` (`titleENG`),
FULLTEXT KEY `lowerTitle` (`lowerTitle`),
FULLTEXT KEY `phone` (`phone`),
FULLTEXT KEY `city_2` (`city`),
FULLTEXT KEY `state_2` (`state`),
FULLTEXT KEY `business_search` (`lowerTitle`,`phone`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=12409005 ;
我正在通过全文进行一些查询,想知道我是否可以使用via LIKE和使用lower()函数等,但速度很快。
有人可以给我一些建议吗?
答案 0 :(得分:0)
您需要做的就是更改所需列的排序规则。例如:
ALTER TABLE `business` CHANGE COLUMN `city` `city` VARCHAR(150) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NOT NULL;
然后您可以使用相同的全文搜索。
答案 1 :(得分:0)