Thursday, January 17, 2008

Oracle : A way to optimize your statistics in oracle

Adding Index and optimizing your query is not enough if you have a very bad statistics in your database, so one way to do it is to have a statistics of your database,schema and tables and oracle is kind enough to give us a tool to use it its called DBMS_STATS. an example here is how to gather stats of a table

SQL>BEGIN
DBMS_STATS.GATHER_TABLE_STATS
( OWNNAME => 'SCOTT',
TABNAME => 'EMP',
ESTIMATE_PERCENT => 99,
METHOD_OPT => 'FOR ALL INDEXED COLUMNS SIZE AUTO',
CASCADE => TRUE
);
END;
/

No comments: