我面临着一种我无法理解和克服的情况。
简而言之,我们有左连接查询,如:
select from a
left join b on a.key1=b.key1 or a.key1=b.key2
Run Code Online (Sandbox Code Playgroud)
这工作非常缓慢,同时两者分开:
select from a
left join b on a.key1=b.key1
select from a
left join b on a.key1=b.key2
Run Code Online (Sandbox Code Playgroud)
工作非常快。
b.key1 有正常索引
b.key2 有正常索引
我无法理解这种行为的原因?我的连接策略或索引使用中是否缺少一些非常基本的东西?
在这里,我们有详细的计划:
无或(TOP_USTR_ADMIN_IP - ustrip 列的索引名称):
SQL> explain plan for
SELECT * FROM top.macs_constraint mc
LEFT JOIN top.top_ustr tu ON tu.ustrip = mc.IP;
Explained.
SQL> SELECT PLAN_TABLE_OUTPUT FROM TABLE(DBMS_XPLAN.DISPLAY());
Plan hash value: 349751289
--------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost …
Run Code Online (Sandbox Code Playgroud)