【发布时间】:2021-06-28 10:21:52
【问题描述】:
select a.id
from (select /*+index(test_table, test_index)*/
row_number() over (partition by a, b, c order by d desc) rn,
id
from test_table
) a
where a.rn = 1
test_index(a, b, c, d)
limit access to 500, cost 9s)
我应该如何解决它
【问题讨论】:
-
您要解决什么问题?请澄清您的问题:描述您目前的情况以及它到底出了什么问题,添加minimal reproducible example 或至少一个query plan 以及您已经执行了哪些步骤来解决问题。
-
我会先删除该提示。没有针对您的 test_table 的 where 子句,因此全表扫描可能比强制它使用索引更快(除非您的索引实际上包含所有列,并且至少其中一个列不可为空)。索引扫描并不总是好的,全表扫描也不总是坏的。
标签: sql oracle analytic-functions