还是一样,
16:45:44 SQL> l
1 select site_id,
2 count(*) sendnum
3 from
4 (select site_id,
5 ewb_no
6 from prod_send t
7 where scan_time >= to_date('2015-05-15', 'yyyy-mm-dd')
8 and scan_time < to_date('2015-05-16', 'yyyy-mm-dd')
9 group by site_id, ewb_no)
10* group by site_id
16:45:51 SQL> /
2793 rows selected.
Elapsed: 00:00:03.71
Execution Plan
----------------------------------------------------------
Plan hash value: 652676349
--------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
--------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 3995 | 15980 | | 162K (1)| 00:32:36 |
| 1 | HASH GROUP BY | | 3995 | 15980 | | 162K (1)| 00:32:36 |
| 2 | VIEW | VM_NWVW_0 | 437K| 1708K| | 162K (1)| 00:32:36 |
| 3 | HASH GROUP BY | | 437K| 10M| 15M| 162K (1)| 00:32:36 |
|* 4 | TABLE ACCESS FULL| PROD_SEND | 437K| 10M| | 159K (1)| 00:31:59 |
--------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
4 - filter("SCAN_TIME">=TO_DATE(' 2015-05-15 00:00:00', 'syyyy-mm-dd
hh24:mi:ss') AND "SCAN_TIME"
hh24:mi:ss'))
Statistics
----------------------------------------------------------
1 recursive calls
0 db block gets
586772 consistent gets
586762 physical reads
0 redo size
57840 bytes sent via SQL*Net to client
2570 bytes received via SQL*Net from client
188 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
2793 rows processed
单独执行里面的子句,也是走全表
16:48:21 SQL> l
1 select site_id,
2 ewb_no
3 from prod_send t
4 where scan_time >= to_date('2015-05-15', 'yyyy-mm-dd')
5 and scan_time < to_date('2015-05-16', 'yyyy-mm-dd')
6* group by site_id, ewb_no
16:48:24 SQL> /
850824 rows selected.
Elapsed: 00:00:08.87
Execution Plan
----------------------------------------------------------
Plan hash value: 2203583913
------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 437K| 10M| | 162K (1)| 00:32:36|
| 1 | HASH GROUP BY | | 437K| 10M| 15M| 162K (1)| 00:32:36|
|* 2 | TABLE ACCESS FULL | PROD_SEND | 437K| 10M| | 159K (1)| 00:31:59|
------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter("SCAN_TIME">=TO_DATE(' 2015-05-15 00:00:00', 'syyyy-mm-dd
hh24:mi:ss') AND "SCAN_TIME"
hh24:mi:ss'))
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
586772 consistent gets
586762 physical reads
0 redo size
25943493 bytes sent via SQL*Net to client
624455 bytes received via SQL*Net from client
56723 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
850824 rows processed