SORT AGGREGATE
2012-01-03 22:44
211 查看
SORT AGGREGATE做为sort的option之一比较特殊,他并不做sort
SORT AGGREGATE作用于所有的data set上,用于aggregate function,例如sum, count, avg, min, max
SQL>
select max(x)
from test;
Execution
Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=3 Card=1 Bytes=5)
1
0 SORT
(AGGREGATE)
2
1 INDEX
(FULL
SCAN (MIN/MAX))
OF 'TEST_IDX'
(NON-UNIQUE)
(
Cost=3
Card=7140
Bytes=35700)
Statistics
----------------------------------------------------------
0 recursive calls
0
db block
gets
2
consistent gets
0
physical reads
0
redo size
491
bytes sent
via SQL*Net
to client
650
bytes received
via SQL*Net
from client
2
SQL*Net
roundtrips
to/from
client
0
sorts (memory) -- no sort here
0
sorts (disk)
1
rows processed
如果aggregate function不是作用于与所有的data set上,还是作用于不同的group上,那么操作类型将会变为SORT (GROUP BY),这时会有sort发生
SQL>
select x,count(*)
from test
group by
x;
7138 rows
selected.
Execution
Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=20 Card=7137 Bytes=3
5685)
1
0 SORT
(GROUP
BY)
(Cost=20
Card=7137
Bytes=35685)
2
1 TABLE
ACCESS (FULL)
OF 'TEST'
(Cost=3
Card=7140
Bytes=35
700)
Statistics
----------------------------------------------------------
0 recursive calls
0
db block
gets
19
consistent gets
0
physical reads
0
redo size
151790
bytes sent
via SQL*Net
to client
5875
bytes received
via SQL*Net
from client
477
SQL*Net
roundtrips
to/from
client
1
sorts (memory)
0
sorts (disk)
7138
rows processed
SORT AGGREGATE作用于所有的data set上,用于aggregate function,例如sum, count, avg, min, max
SQL>
select max(x)
from test;
Execution
Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=3 Card=1 Bytes=5)
1
0 SORT
(AGGREGATE)
2
1 INDEX
(FULL
SCAN (MIN/MAX))
OF 'TEST_IDX'
(NON-UNIQUE)
(
Cost=3
Card=7140
Bytes=35700)
Statistics
----------------------------------------------------------
0 recursive calls
0
db block
gets
2
consistent gets
0
physical reads
0
redo size
491
bytes sent
via SQL*Net
to client
650
bytes received
via SQL*Net
from client
2
SQL*Net
roundtrips
to/from
client
0
sorts (memory) -- no sort here
0
sorts (disk)
1
rows processed
如果aggregate function不是作用于与所有的data set上,还是作用于不同的group上,那么操作类型将会变为SORT (GROUP BY),这时会有sort发生
SQL>
select x,count(*)
from test
group by
x;
7138 rows
selected.
Execution
Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=20 Card=7137 Bytes=3
5685)
1
0 SORT
(GROUP
BY)
(Cost=20
Card=7137
Bytes=35685)
2
1 TABLE
ACCESS (FULL)
OF 'TEST'
(Cost=3
Card=7140
Bytes=35
700)
Statistics
----------------------------------------------------------
0 recursive calls
0
db block
gets
19
consistent gets
0
physical reads
0
redo size
151790
bytes sent
via SQL*Net
to client
5875
bytes received
via SQL*Net
from client
477
SQL*Net
roundtrips
to/from
client
1
sorts (memory)
0
sorts (disk)
7138
rows processed
相关文章推荐
- mongodb笔记04(MongoDB $type 操作符,Limit与Skip方法,sort()方法,索引,聚合(aggregate))
- [Oracle]-[SORT AGGREGATE]-count与索引
- 大数据Spark “蘑菇云”行动第40课:Spark编程实战之aggregateByKey、reduceByKey、groupByKey、sortByKey深度解密
- SORT UNIQUE|AGGREGATE|GROUP BY|ORDER BY|JOIN
- SORT AGGREGATE-count与索引
- HDU 1425 sort
- 单链表元素排序(Insertion sort list)
- 451. Sort Characters By Frequency**
- std list/vector sort 排序
- linux sort 设定tab分隔符
- Python3基础 list sort 从小(大)到大(小)排序
- C++ 排序函数 sort(),qsort()的用法
- 排序算法 Sleep Sort
- 桶排序(Bucket Sort)
- Map 按值排序 (Map sort by value) - Java
- PAT 1098. Insertion or Heap Sort
- sort用法
- STL sort详解
- [LeetCode 147] Insertion Sort List
- Leetcode——75. Sort Colors