Oracle SQL in clause - slow in speed



下面的查询 1 的速度真的很慢。

select * from my_table
where col1 in (
... multiple complicated joins ...
);

假设(多个复杂连接(返回 1,2,...,50 并且运行速度很快。

... multiple complicated joins ...

通过将联接替换为其输出,下面的 Query2 也运行得更快。

select * from my_table
where col1 in (
1,2,...,50
);

有没有办法将(多个复杂连接(的输出插入到类似列表的变量中?

select * from my_table
where col1 in &col1_list;

my_table:2G 表和 col1 未编制索引

多个复杂连接:在 1 秒内返回大约 50 个值

查询 1:运行时间 = 5 分钟

查询 2:运行时间 = 2 秒

注意:我只有对数据库的读取权限,因此无法创建任何临时表。

如何加入您的复杂连接。

SELECT * FROM MY_TABLE mt JOIN (... multiple complicated joins ...)temp on temp.col = mt.col1

最新更新