因此,我正在尝试优化一组需要花费大量时间的查询。我想弄清楚的是如何为来自不同表的列创建索引。这里是我的问题的一个简单版本。
我做了什么,
在谷歌搜索之后,我查看了位图索引,但我不确定这是否是解决问题的正确方法。
问题
查询
Select *
from Report
inner join StudentReport on Report.rid = StudentReport.rid
where Report.isdeleted = 0 and StudentReport.sid = x and Report.year = y创建索引的最佳方法是什么?
发布于 2014-09-29 05:33:11
请试试这个:
with TMP_REP AS (
Select * from Report where Report.isdeleted = 0 AND Report.year = y
)
,TMP_ST_REP AS(
Select *
from StudentReport where StudentReport.sid = x
)
SELECT * FROM TMP_REP R, TMP_ST_REP S WHERE S.rid = R.ridhttps://stackoverflow.com/questions/18478317
复制相似问题