Search notes:
Oracle: Unnested Subqueries using the FILTER plan operator
create table tq84_A (id number, tx varchar2(3));
create table tq84_B (id_a number);
insert into tq84_A select level*37, 'X' from dual connect by level < 1000;
insert into tq84_B select level+91 from dual connect by level < 600;
begin
dbms_stats.gather_table_stats(user, 'tq84_A');
dbms_stats.gather_table_stats(user, 'tq84_B');
end;
/
explain plan for
select /*+ no_unnest(@subquery) */
id,
tx
from
tq84_A
where
id in (select /*+ qb_name(subquery) */ id_a from tq84_B);
select * from table(dbms_xplan.display(format=>'basic'));
--
-- -------------------------------------
-- | Id | Operation | Name |
-- -------------------------------------
-- | 0 | SELECT STATEMENT | |
-- |* 1 | FILTER | |
-- | 2 | TABLE ACCESS FULL| TQ84_A |
-- |* 3 | TABLE ACCESS FULL| TQ84_B |
-- -------------------------------------
--
-- Predicate Information (identified by operation id):
-- ---------------------------------------------------
--
-- 1 - filter( EXISTS (SELECT /*+ NO_UNNEST QB_NAME ("SUBQUERY") */ 0
-- FROM "TQ84_B" "TQ84_B" WHERE "ID_A"=:B1))
-- 3 - filter("ID_A"=:B1)
drop table tq84_A;
drop table tq84_B;