3:收集统计信息后,user_tables视图相应的内容会被填充,禁用动态采样也能获取正确的执行计划
- SQL> set autot off
- SQL> exec dbms_stats.gather_table_stats('HR','T2',CASCADE=>TRUE);
- PL/SQL procedure successfully completed.
- SQL> select num_rows,avg_row_len,blocks,last_analyzed from user_tables where tab
- le_name='T2';
- NUM_ROWS AVG_ROW_LEN BLOCKS LAST_ANALYZED
- ---------- ----------- ---------- -------------------
- 77266 29 381 2012-06-07:14:05:52
- SQL> select blevel,leaf_blocks,distinct_keys,num_rows,last_analyzed from user_in
- dexes where table_name='T2';
- BLEVEL LEAF_BLOCKS DISTINCT_KEYS NUM_ROWS LAST_ANALYZED
- ---------- ----------- ------------- ---------- -------------------
- 1 171 77265 77265 2012-06-07:14:05:52
- SQL> set autot traceonly
- SQL> select /*+ dynamic_sampling(t2 0) */ * from t2 where object_id > 30;
- 77236 rows selected.
- Execution Plan
- ----------------------------------------------------------
- Plan hash value: 1513984157
- --------------------------------------------------------------------------
- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
- --------------------------------------------------------------------------
- | 0 | SELECT STATEMENT | | 77242 | 2187K| 106 (1)| 00:00:02 |
- |* 1 | TABLE ACCESS FULL| T2 | 77242 | 2187K| 106 (1)| 00:00:02 |
- --------------------------------------------------------------------------
- Predicate Information (identified by operation id):
- ---------------------------------------------------
- 1 - filter("OBJECT_ID">30)
- Statistics
- ----------------------------------------------------------
- 12 recursive calls
- 0 db block gets
- 5516 consistent gets
- 0 physical reads
- 0 redo size
- 3005346 bytes sent via SQL*Net to client
- 57059 bytes received via SQL*Net from client
- 5151 SQL*Net roundtrips to/from client
- 5 sorts (memory)
- 0 sorts (disk)
- 77236 rows processed
本文以《让Oracle跑的更快》为指导,如有雷同,不胜荣幸!
