統計情報

Oracleの統計情報を取得するコマンド

-- 100%のサンプリングを行う
analyze &OBJECT_NAME compute statistics ;
-- 指定した%のサンプリングを行う。
analyze &OBJECT_NAME estimate statistics sample &percent%;

基準として表については25%、索引については100%でサンプリングするのがよい。
また、テーブルの統計情報を取得した場合は、索引もサンプリングされる。
この時、索引はcomputeでanalyzeされる。
サンプリングの%を25%以上にすると、computeと同じになる。

      • 2007/12/30追記

Oracle10gはDBMS_STATS.GATHER_SCHEMA_STATSを推奨。
http://otndnld.oracle.co.jp/document/products/oracle10g/102/doc_cd/appdev.102/B19245-01/d_stats.htm