<pre name="code" class="sql">关于group by 排序问题
10g 以前sort group by 需要排序
10g 以后 hash group by 不需要排序
SQL> set linesize 200
SQL> set pagesize 200
SQL> set autot trace
SQL> select owner,count(*) from t1 group by owner;
已选择30行。
执行计划
----------------------------------------------------------
Plan hash value: 136660032
---------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 30 | 180 | 2014 (2)| 00:00:25 |
| 1 | HASH GROUP BY | | 30 | 180 | 2014 (2)| 00:00:25 |
| 2 | TABLE ACCESS FULL| T1 | 580K| 3403K| 1998 (1)| 00:00:24 |
---------------------------------------------------------------------------
统计信息
----------------------------------------------------------
0 recursive calls
0 db block gets
8323 consistent gets
8313 physical reads
0 redo size
1059 bytes sent via SQL*Net to client
426 bytes received via SQL*Net from client
3 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
30 rows processed