以下是我的查询,大约1分钟需要一些时间,有时会在一秒内给出结果, 特别是我在一段时间之后执行查询,或者在查询中添加了一些新关键字。 看起来像是一些索引问题,当我执行执行计划时,RID查找成本为60%。源表有大约2-5个Lacs数据,每天大约10,000-20,000行将被添加。请建议我。感谢
SELECT *
FROM (SELECT Row_number() OVER (ORDER BY rank DESC, jobid DESC) AS rnum,
*
FROM (SELECT rank,
joblistview.*
FROM joblistview,
FREETEXTTABLE(joblistview, jobtitle, 'seo manager') f
WHERE joblistview.jobid = f.[key]
AND CONTAINS(joblistview.joblocation, 'mumbai')
UNION
SELECT rank,
joblistview.*
FROM joblistview,
FREETEXTTABLE(joblistview, jobdescription, 'seo manager')
f
WHERE joblistview.jobid = f.[key]
AND CONTAINS(joblistview.joblocation, 'mumbai')
UNION
SELECT rank,
joblistview.*
FROM joblistview,
FREETEXTTABLE(joblistview, company_name, 'seo manager') f
WHERE joblistview.jobid = f.[key]
AND CONTAINS(joblistview.joblocation, 'mumbai')) AS xx)AS
tt
WHERE rnum BETWEEN 11 AND 20
执行计划
答案 0 :(得分:0)
您可以在单个FREETEXTTABLE搜索中指定多个列,这样就不需要使用UNION进行多次查询。
SELECT *
FROM (SELECT Row_number() OVER (ORDER BY rank DESC, jobid DESC) AS rnum,
*
FROM (SELECT rank,
joblistview.*
FROM joblistview,
FREETEXTTABLE(joblistview, (jobtitle,jobdescription,company_name), 'seo manager') f
WHERE joblistview.jobid = f.[key]
AND CONTAINS(joblistview.joblocation, 'mumbai')
) AS xx
) AS tt
WHERE rnum BETWEEN 11 AND 20
答案 1 :(得分:0)
您是否尝试添加包含所有搜索列数据的计算列?然后将此计算列配置为持久化并使其成为全文索引。然后你可以尝试
SELECT *
FROM (SELECT Row_number() OVER (ORDER BY rank DESC, jobid DESC) AS rnum,
*
FROM (SELECT rank,
joblistview.*
FROM joblistview,
FREETEXTTABLE(joblistview, (<<<ComputedColumn>>>), 'seo manager') f
WHERE joblistview.jobid = f.[key]
AND CONTAINS(joblistview.joblocation, 'mumbai')
) AS xx
) AS tt
WHERE rnum BETWEEN 11 AND 20