1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Indexが実行計画に反映されず遅い! Oracle

Posted at

インデックスはテーブルの再作成などの影響で削除される。
また、再作成してもUNUSABLEのステータスとなって名前の通り使用できなくなる模様。(必ずかは不明)

実行計画立てる際にUSUSABLEのIndexを使用しようとしてエラーを吐くとかはなく、使わず実行計画を立てる。
なので影響が大きくない場合は気づかないかもしれない。

ALTER INDEX [Index名] REBUILD;
とするとVALIDのステータスとなり使用可能になる。

今回気づいた経緯は、
・バッチが異常に遅くなった
→調べると SQLが遅い
→別の環境では早い
→実行計画見直す
→Indexが遅い環境では動いてない
→ヒント句でIndex強制使用
→java.sql.SQLException: ORA-01502: 索引'[索引名]'またはそのパーティションが使用不可の状態です。
→ select index_name, status from all_indexes where index_name = '[索引名]';
→UNUSABLE だった!

Index 作り直すだけで大丈夫なんだと思ってました。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?