Force Statistics

I had a situation where I had to “force” statistics for particular tables, this is how I did it. [code language=”sql”] #!/bin/ksh # # Forcing stats for specific tables # # —   dbms_stats.set_table_stats( ‘PPTEST’, ‘IMAGE306’, numrows=&gt; 2000000 ); # #################################################################################### sqlplus -s "/ as sysdba" <<EOF –begin —   dbms_stats.set_table_stats( ‘PPTEST’, ‘ITEM301’, numrows=> 2000000 ); —   […]

Gathering Stats

[code language=”sql”] exec DBMS_STATS.GATHER_TABLE_STATS( ownname=>’SCHEMA_OWNER’, tabname=>’SOME_TABLE’, degree=>16, estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE, method_opt => ‘FOR ALL COLUMNS SIZE AUTO’, granularity => ‘AUTO’, cascade => TRUE, no_invalidate => FALSE); [/code]