【发布时间】:2020-09-07 08:44:56
【问题描述】:
我遇到了优化问题。
当我使用这样的查询时:
Select * (around 100 columns)
from x
where RepoDate = '2020-05-18'
大约需要 0.2 秒。
除非我使用这样的查询:
Select * (around 100 columns)
from x
where RepoDate = (select max(RepoDate) from y)
大约需要 1 小时。
表 y 只有日期 (2020-05-17, 2020-05-18, ...)
你能告诉我为什么执行时间有这么大的差异吗?
【问题讨论】:
-
'2020-05-18'不是DATE开头的,因为它是一个字符串。其次,SQL Developer是一个工具,不确定它与查询性能有什么关系。第三,我们既没有您的table/data也没有任何explain plan或performance metrics来说明您的查询为什么慢/快/随便? -
在您提供更多详细信息之前,我们无法给出答案。请阅读this excellent post on asking Oracle tuning questions。
-
Y中有多少行?X有多少个?这两个执行计划是什么? -
你能为查询提供一个解释计划吗?
标签: sql oracle performance oracle10g query-optimization