ANALYZE TABLE employee COMPUTE STATISTICS
create table emp(
no integer primary key
,name varchar2(20) not null
,region number
,sales number
);
insert into emp(no, name, region, sales)
values (1, 'Tom', 100, 10000);
insert into emp(no, name, region, sales)
values (2, 'Tom', 200, 20000);
insert into emp(no, name, region, sales)
values (3, 'Tom', 200, 30000);
insert into emp(no, name, region, sales)
values (4, 'Tom', 100, 40000);
Execution Plan
----------------------------------------------------------
Plan hash value: 1624656943
-------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 9 | 234 | 3 (34)| 00:00:01 |
| 1 | HASH GROUP BY | | 9 | 234 | 3 (34)| 00:00:01 |
| 2 | TABLE ACCESS FULL| EMPLOYEE | 9 | 234 | 2 (0)| 00:00:01 |
-------------------------------------------------------------------------------
Note
-----
- dynamic sampling used for this statement
SELECT region, SUM(sales)
FROM emp
GROUP BY region;
REGION SUM(SALES)
---------- ----------
100 50000
200 50000
2 rows selected.
Statistics
----------------------------------------------------------
48 recursive calls
0 db block gets
11 consistent gets
0 physical reads
0 redo size
479 bytes sent via SQL*Net to client
380 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL>
SQL> set autotrace off
SQL>
SQL> ANALYZE TABLE employee COMPUTE STATISTICS;
Table analyzed.
Related examples in the same category