【发布时间】:2012-05-18 04:34:59
【问题描述】:
我正在使用 Oracle 11g 文本,
AuthorTable:(作者详细信息表) AuthorId、AuthorName、AuthorDOB
ArticleTable:(文章内容表)ArticleId、WrittenDate、PublishDate、ARTICLE_TXT (CLOB)
LocationTable:(位置表)LocationId、LocationState、LocationCity
ArticleAuthorAssocTable:(文章-作者关联表)AuthorId、ArticleId
LocAuthorAssocTable:(作者-位置关联表)AuthorId、LocationId、LocationStartDate、LocationEndDate
我的查询需要搜索 ARTICLE_TXT 上的任何输入搜索词以及 PublishDate / WrittenDate / AuthorDOB / LocationCity / LocationStartDate 范围上的任何其他查询。
由于必须进行混合查询,我开始在 ArticleTable 上创建复合域索引 CDI。
CREATE INDEX ARTICLE_TXT_CDI_IDX ON ArticleTable(ARTICLE_TXT)
INDEXTYPE IS ctxsys.CONTEXT
FILTER BY WrittenDate, PublishDate
查询为
SELECT
/*+ domain_index_sort domain_index_filter(ARTICLE_TXT_CDI_IDX) */ article.ARTICLE_TXT,
author.AuthorName , article.WrittenDate, article.PublishDate, LocationTable.LocationCity ,location.LocationStartDate, location.LocationEndDate
FROM
ArticleTable article
INNER JOIN
ArticleAuthorAssocTable articleAuthorAssoc ON article.articleId = articleAuthorAssoc .articleId
INNER JOIN
AuthorTable author ON author.authorId= articleAuthorAssoc.authorId
INNER JOIN
LocAuthorAssocTable locAuthorAssoc req ON author.authorId = locAuthorAssoc.authorId
INNER JOIN
LocationTable location ON location .authorId = locAuthorAssoc.authorId
WHERE
CONTAINS(article.ARTICLE_TXT, 'Something') >0
AND author.AuthorDOB BETWEEN TO_DATE('01/01/2001','MM/DD/YYYY')
AND TO_DATE('12/31/2012','MM/DD/YYYY')
AND location.LocationId IN (1,2)
现在我的问题是:
- 是否可以使用 FILTER BY 创建复合域索引 来自不同表的列?
- 还有其他方法可以改进上述查询吗?
根据我的研究,一些选项使用物化视图、基于函数的索引、USER_DATASTORE
但不幸的是,仍然不确定如何使用它们...请帮助我了解您的知识。
谢谢
【问题讨论】:
标签: oracle indexing dns composite oracle-text