select dept_no, count(m2d.m_2_d_id) as all_count
from a_m_plan_day m2d,
a_m_plan_series series,
a_m_plan_class planClass,
a_m_plan_prj prj
where m2d.m_plan_prj_id = prj.m_plan_prj_id and
prj.m_plan_class_id = planClass.m_plan_class_id and
planClass.m_series_id = series.m_series_id and
series.month_period = substr('20071100', 0, 6) and
dept_no in ('00242102')
group by dept_no
SQL> /
DEPT_NO
--------------------------------------------------------------------------------
ALL_COUNT
----------
00242102
1407
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=28 Card=17 Bytes=113
9)
1 0 SORT (GROUP BY NOSORT) (Cost=28 Card=17 Bytes=1139)
2 1 NESTED LOOPS (Cost=28 Card=17 Bytes=1139)
3 2 MERGE JOIN (CARTESIAN) (Cost=28 Card=108888 Bytes=6424
392)
4 3 NESTED LOOPS (Cost=5 Card=1 Bytes=55)
5 4 TABLE ACCESS (FULL) OF 'A_M_PLAN_SERIES' (Cost=4 C
ard=1 Bytes=48)
6 4 INDEX (RANGE SCAN) OF 'IDX_M_PLAN_CLASS' (UNIQUE)
(Cost=1 Card=6470 Bytes=45290)
7 3 BUFFER (SORT) (Cost=27 Card=9 Bytes=36)
8 7 INDEX (FAST FULL SCAN) OF 'IDX_M_PLAN_DAY' (NON-UN
IQUE) (Cost=23 Card=9 Bytes=36)
9 2 INDEX (UNIQUE SCAN) OF 'IDX_M_PLAN_PRJ' (UNIQUE)
Statistics
----------------------------------------------------------
0 recursive calls
2 db block gets
10389847 consistent gets
15429 physical reads
0 redo size
562 bytes sent via SQL*Net to client
655 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
1 sorts (disk)
1 rows processed
SQL> /