Mega Code Archive

 
Categories / Oracle PLSQL / SQL Plus
 

Analyze table compute statistics for all indexes

SQL>  set serveroutput on SQL>  set echo on SQL> SQL> SQL>  create table t   2     ( x, y null, primary key (x) )   3     as   4     select rownum x, username   5      from all_users   6      where rownum <= 100; Table created. SQL> SQL>  analyze table t compute statistics; Table analyzed. SQL> SQL> SQL>  analyze table t compute statistics for all indexes; Table analyzed. SQL> SQL> SQL>  set autotrace on explain SQL> SQL>  select count(y) from t where x < 50;   COUNT(Y) ----------         14 1 row selected. Execution Plan -------------------------------------------------- Plan hash value: 2966233522 -------------------------------------------------- ------------------------- | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     | -------------------------------------------------- ------------------------- |   0 | SELECT STATEMENT   |      |     1 |     8 |     2   (0)| 00:00:01 | |   1 |  SORT AGGREGATE    |      |     1 |     8 |            |          | |*  2 |   TABLE ACCESS FULL| T    |    14 |   112 |     2   (0)| 00:00:01 | -------------------------------------------------- ------------------------- Predicate Information (identified by operation id) : -------------------------------------------------- -    2 - filter("X"<50) SQL> SQL>  drop table t; Table dropped. SQL> SQL>  set autotrace off SQL> --