我正在使用 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
但不幸的是,仍然不知道如何使用它们......请用你的知识帮助我。
谢谢