Virtual Indexes in Oracle
今日はDBA support.comよりVirtual Indexに関する 記事をご紹介します。 Virtual Indexはその名の通り実際のセグメントを使用 せずに仮想的なIndexを作成し、実行計画でCBO (コストベースオプティマイザ)がそのIndexを実際に 使用するかどうかを確認したい場合などに活用すること が可能です。 今回はその記事の中からVirtual Indexの特徴を列挙 している部分をピックアップしたいと思います。 実際のVirtual Indexの使用方法は引用ページで サンプル付きで説明されています。 ■ DBA Support.com http://www.dbasupport.com/ ■ 引用ページ http://www.dbasupport.com/oracle/ora9i/virtual_indexes.shtml _________________________  ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ 記事本文 _________________________  ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ◆ Virtual Indexes in Oracle Below are some attributes of the Virtual Indexes. 1. These are permanent and continue to exist unless we drop them. 2. Their creation will not affect existing and new sessions. Only sessions marked for Virtual Index usage will become aware of their existence. 3. Such indexes will be used only when the hidden parameter "_use_nosegment_indexes" is set to true. 4. The Rule based optimizer did not recognize Virtual Indexes when I tested, however, CBO recognizes them. In all of my examples, I have used CBO. However, I did not carry out intensive testing in RBO and you may come across exceptions to this view. 5. Dictionary view DBA_SEGMENTS will not show an entry for Virtual Indexes. The table DBA_INDEXES and DBA_OBJECTS will have an entry for them in Oracle 8i; in Oracle 9i onwards, DBA_INDEXES no longer show Virtual Indexes. 6. Virtual Indexes cannot be altered and throw a "fake index" error! 7. Virtual Indexes can be analyzed, using the ANALYZE command or DBMS_STATS package, but the statistics cannot be viewed (in Oracle 8i, DBA_INDEXES will not show this either). Oracle may be generating artificial statistics and storing it somewhere for referring it later. _________________________  ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ 英語の解釈 _________________________  ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ◆ Virtual Indexes in Oracle Below are some attributes of the Virtual Indexes. 以下はVirtual Indexのいくつかの特徴です。 1. These are permanent and continue to exist unless we drop them. これらはDropしないかぎり永続的,継続的に存在します。 2. Their creation will not affect existing and new sessions. これらの作成は現在または新しいセッションに影響しません Only sessions marked for Virtual Index usage will become aware of their existence. Virtula Index使用を明示したセッションのみこれらの存在を認識します。 3. Such indexes will be used only when the hidden parameter "_use_nosegment_indexes" is set to true. それらのIndexは隠しパラメータ_use_nosegment_indexsがtrueの場合 のみ使用されます。 4. The Rule based optimizer did not recognize Virtual Indexes when I tested, 私がテストした時、RBOではVirtual Indexesは認識されませんでした。 however, CBO recognizes them. しかしながら、CBOではそれらを認識します。 In all of my examples, I have used CBO. 私の例においてはCBOを使用していました。 However, I did not carry out intensive testing in RBO しかしながら、RBOについて私は良くテストしませんでした。 and you may come across exceptions to this view. そしてあなたはもしかするとこの点について 例外に出くわすかもしれません 5. Dictionary view DBA_SEGMENTS will not show an entry for Virtual Indexes. DBA_SEGMENTSではVirtula Indexは表示されません。 The table DBA_INDEXES and DBA_OBJECTS will have an entry for them in Oracle 8i; 8iではDBA_INDEXESとDBA_OBJECTSにはそれらのエントリが保持されます。 in Oracle 9i onwards, 9i以降では DBA_INDEXES no longer show Virtual Indexes. DBA_INDEXESには表示されなくなりました。 6. Virtual Indexes cannot be altered Virtual Indexはalterできません。 and throw a "fake index" error! そして"fake index"errorを返します。 7. Virtual Indexes can be analyzed, Virtual IndexはAnalyzeできます。 using the ANALYZE command or DBMS_STATS package, AnlayzeコマンドかDBMS_STATSパッケージで but the statistics cannot be viewed ただし統計情報は参照できません。 (in Oracle 8i, DBA_INDEXES will not show this either). 8iのDBA_INDEXESビューではこれらを表示しません。 Oracle may be generating artificial statistics Oracleは擬似的な統計を収集しているのだと思います。 and storing it somewhere そしてどこかに蓄積しているのだと思います。 for referring it later. 後で参照するために。 _________________________  ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ 解釈のポイント _________________________  ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ Only sessions marked for Virtual Index usage will become aware of their existence. (※)markedからusageまではsessionの説明 Only sessions will become aware of their existence. (sessions = marked for Virtual Index usage) usage = 使い方 aware = 気づいている Such indexes will be used only when the hidden parameter "_use_nosegment_indexes" is set to true. (※)when以降で使用される条件を後付けで説明している The Rule based optimizer did not recognize Virtual Indexes when I tested, (※)記者がRBOで認識しないことが確実だと判断できなかったので 過去形で自分がテストした時だけに特定している < RBOについては解説を参照 > I did not carry out intensive testing (※)carry out = 遂行する intensive = 激しく、集中的に and you may come across exceptions (※)come across = 偶然出くわす in Oracle 9i onwards, (※)onwards = 前方に(10gも9iと同様) DBA_INDEXES no longer show Virtual Indexes. (※)no longer = もはや 〜 ではない and throw a "fake index" error! (※)throw : 例外の発行はthrowという動詞が使われる場合があります。 Oracle may be generating artificial statistics (※)artificial = 擬似的に作成された,人工的な (主に人によってだが今回はOracleによって) _________________________  ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ 解説 _________________________  ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ 巨大なTableにIndexを作成する場合、1時間以上 かかってしまう場合があります。 そのTableにPerformance Troubleが発生し、 かつ緊急に解決しなければならない場合は 実験的にIndexをいくつも作成する猶予がありません。 そんな場合に有効活用できるかもしれませんね。 ※Virtual Index機能はOracle側で公式にDocument化 されていない機能の1つで自己リスクでの使用となります。 ご注意ください。 RBO : (rule based optimizer) SQLの実行計画を決定するoptimizerの種類 RBOは統計情報を使用せずに決まった条件で 実行計画を判断する。統計情報を使用しないので レコード数が多くても少なくても実行計画が 同じになる。極端な例では1行しかレコードがない テーブルをわざわざINDEXを使って検索したりします。 10gからはデフォルトでCBOとなり、 RBOはサポート対象外となりました。 CBO : (cost based optimizer) RBOとは異なり、実行計画の決定に 統計情報などを元に一定の条件で算出された COSTを使用するoptimizerです。 その為、analyzeまたはdbms_statsによる 統計情報の収集タイミングについて考慮しなければ なりません。 また10gではデフォルトでdbms_statsによる 統計情報収集が平日22時から実施されるので 注意が必要です。 ※AnalyzeとDBMS_STATSは同一DB内で混在させない ようにする必要があります。 _________________________  ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ 編集後記 _________________________  ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ 2回目の発行となりましたが、まだ慣れないです。 できるだけ短くコンパクトにまとめたいのですが どうしても冗長的になってしまいます。 次回は特に新しい情報がなければ、 同サイトで紹介されているもうひとつの Undocumented Featureであるalert log,trace file へのinsert処理についてとりあげようと思います。 それではまた。 ___________________________________  ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ おわりに ___________________________________  ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ 記述誤りなどのご指摘、 記事に関する疑問点・質問・感想・ご意見・ご感想など yakusa_oracle@yahoo.co.jpまでお願い致します。 簡単な自己紹介はこちら http://pr2.cgiboy.com/S/3191274 バックナンバー兼ブログはこちら http://imoment.web.fc2.com/ 登録・解除はこちらから http://www.mag2.com/m/0000200441.htm