我有一个视图,基于我的数据库中的表'items':
v_items_search:
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost`
SQL SECURITY DEFINER VIEW `v_items_search` AS
select
`items`.`id` AS `id`,
`items`.`res_id` AS `res_id`,
`items`.`nd_date` AS `nd_date`,
`items`.`not_date` AS `not_date`,
`items`.`title` AS `title`,
`items`.`content` AS `content`,
concat(`items`.`title`, ' ', `items`.`content`) AS `text`
from `items`;
项目:
CREATE TABLE IF NOT EXISTS `items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`log_id` int(11) NOT NULL,
`res_id` int(11) NOT NULL,
`link` varchar(255) NOT NULL,
`title` text NOT NULL,
`content` text NOT NULL,
`n_date` varchar(255) NOT NULL,
`nd_date` int(11) NOT NULL,
`s_date` int(11) NOT NULL,
`not_date` date NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `link_2` (`link`),
KEY `log_id` (`log_id`),
KEY `res_id` (`res_id`),
KEY `now_date` (`not_date`),
KEY `sql_index` (`res_id`,`id`,`not_date`)
) ENGINE=Aria DEFAULT CHARSET=utf8 PAGE_CHECKSUM=0 AUTO_INCREMENT=18382133 ;
我有php脚本analyzer.php
,它在这个视图中实现了serching。
例如,它接收一些标签和句点(not_date)并在视图中搜索它:
SELECT R.RESOURCE_NAME, R.RESOURCE_LOGO, I.*
FROM v_items_search I, resource R, countries C
where I.not_date>='".$s_date."'
and I.not_date<='".$f_date."'
and (I.text like '%hellow% or I.text like '%world%')
AND R.RESOURCE_ID = I.res_id
AND R.COUNTRY_ID = I.res_id
AND R.COUNTRY_ID = C.id
order by not_date asc, nd_date asc.
如果期限超过2个月,分析仪将期间分为10个部分。然后它运行10个查询,延迟1分钟。完成最后一部分后,它会收集所有数据。通过这种方式,年度查询可能需要40到100多分钟。这对我来说太长了。考虑到,旧的分析器不会划分长期查询和 根本无法完成。
如何才能让这个过程更快?提前谢谢你......