how do oracle filter data? [message #551953] |
Sun, 22 April 2012 21:18 |
|
zengmuansha
Messages: 26 Registered: April 2012
|
Junior Member |
|
|
t_user(id,name,provcode,areacode,salary)
the table have no index,key,partiton.
it have 3,000,000 rows
the sql
select provcode,sum(salary)
from t_user
where provcode in (1,2,3,4,5)
group by provcode
the sql plant
----------------------------------------------------------
Plan hash value: 2578068701
-----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 26 | 3 (34)| 00:00:01 |
| 1 | HASH GROUP BY | | 1 | 26 | 3 (34)| 00:00:01 |
|* 2 | TABLE ACCESS FULL| T_USER | 1 | 26 | 2 (0)| 00:00:01 |
----------------------------------------------------------------------------- Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter("PROVCODE"=1 OR "PROVCODE"=2 OR "PROVCODE"=3 OR
"PROVCODE"=4 OR "PROVCODE"=5)
Note
-----
- dynamic sampling used for this statement
I want it that filter step
1 read all block into buffer
2 filter no include rows block
3 fetch rows from include rows block into new buffer block
4 fetch columns from new buffer block into new buffer block
5 sort include a few columns block
6 goup by and sum rows
7 send result to USER
I want the oracle filter setp is True?
Why temp table is faster than direct sum()?
the temp table :
1 create t_user_temp(provcode,salary)
2 insert into t_user_temp
select provcode,salary
from t_user
where provcode in (1,2,3,4,5)
3 select provcode sum(salary)
from t_user_temp
|
|
|
|
|
|
|
|
|
|