« Home | Building an Ajax Memory Tree » | Approach 4: Using Regular Expressions » | Oracle Database 10g: Top Features for DBAs Release... » | Project Lockdown 2 » | Build Your Own Oracle RAC 10g Release 2 Cluster on... » | Inserting Custom Messages in Oracle Alert/Trace files » | Virtual Indexes in Oracle » | Project Lockdown » | 11g Performance & Scalability Features » | Bryce DeWitt »

What is your experience with cursor_sharing?

今日は、前回に引き続きdba-villageから
imhoと呼ばれるコーナーをご紹介したいと思います。

Imhoとはin my humble opinionの略で、比較的控えめな
意見を言う場合に前後に(通常大文字で)付け加えます。

例)
IMHO I think you can only shrink a tablespace
as far as there isn't any data.

I think you can only shrink a tablespace as far as
as far as there isn't any data (IMHO).

dba-villageではあるテーマを題材にして
皆さんのimhoを投稿するコーナーがあります。
今回はテーマはcursor_sharingパラメータです。

このパラメータはかなり有名だと思いますが、
本番環境にいきなり適用するのは危険な
パラメータだと考えています。

8iから存在するパラメータにも関わらず
非常にバグの多いパラメータなので、
私は本番環境に適用した経験はありません。
パフォーマンスチューニングの際に
バインド変数化対応が有効であるかどうかを
確認する際に実験的に使用する程度に
留めておいた方が良いというのが私のimhoです。

実際に投稿されているimhoも同じような意見が
多いですね。

dba-villageへの入村には無償ユーザ登録が必要になります。

■ dba-village
http://www.dba-village.com/village/
■ 引用ページ
http://www.dba-village.com/village/dvp_imho.Main

_________________________
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
記事本文
_________________________
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
◆ What is your experience with cursor_sharing?

Did you ever need to set cursor_sharing to its
non-default value? Did it help you? Could you
say how much or what impact it had?

Did you ever had any negative experiences with
this parameter? Would you dare changing it on a
production system without extended testing in
advance? Have you ever encountered any bugs with
it? In what version? Is it stable enough in 10g?

_________________________
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
英語の語順に近い解釈
_________________________
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
※英語を素早く理解する癖をつけるためにあえて
不自然な日本語で、英語の語順で訳しています。

翻訳を仕事とする予定が無い限り、
自然な日本語に訳してから解釈するよりも
目に飛び込んできた英語からどんどん
解釈していくことをお勧めします。


◆ What is your experience
あなたの経験はなんですか?

with cursor_sharing?
cursor_sharingにおける。

Did you ever need
必要になったことはありますか?

to set cursor_sharing
cursor_sharingをセットする

to its non-default value?
default以外の値に

Did it help you?
それはあなたを助けましたか?

Could you say
あなたは言えますか?

how much or what impact it had?
どの程度、またはどのような影響をもたらしたか

Did you ever had
あなたは持っていましたか?

any negative experiences
ネガティブな経験

with this parameter?
このパラメータにおける

Would you dare changing it
思い切ってそれを変更しますか?

on a production system
本番システム上で

without extended testing
幅広いテスト抜きで

in advance?
事前に

Have you ever encountered
あなたは直面したことがありますか?

any bugs with it?
それに関するなんらかのバグに

In what version?
どのバージョン?

Is it stable enough in 10g?
10gでそれは充分安定していますか?

_________________________
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
解説
_________________________
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
cursor_sharingはリテラル値が異なるだけのSQLを
同一のSQLとして解釈するためのパラメータです。

バインド変数を使用せずにリテラル値を
使用しているSQLがある場合、
通常はそのリテラル値が異なる場合は
別のSQLとして解析が行われ、ライブラリキャッシュに
別々に保存されます。

例えば以下のようなSQLが発行されるとOracleは
それぞれのSQLをまったく別のものとして扱います。

w_saraly := 500;
w_emp_no := 1;
sqltext := 'update emp set salary=' || w_saraly || 'where emp_no=' || w_emp_no;
execute immediate sqltext;
w_saraly := 600;
w_emp_no := 2;
sqltext := 'update emp set salary=' || w_saraly || 'where emp_no=' || w_emp_no;
execute immediate sqltext;

このような類似SQLが何万件も立て続けに発行される
プログラムがある場合、数時間の処理遅延が発生する
可能性があります。

対応策としては以下のようなバインド変数化です。

w_saraly := 500;
w_emp_no := 1;
sqltext := 'update emp set salary=:bind_1 where emp_no=:bind_2'
execute immediate sqltext using in w_saraly,w_emp_no;
w_saraly := 600;
w_emp_no := 2;
sqltext := 'update emp set salary=:bind_1 where emp_no=:bind_2'
execute immediate sqltext using in w_saraly,w_emp_no;

上記のようなプログラム変更が難しい場合に
cursor_sharing=similarを初期化パラメータとして設定すると
リテラル値が異なる場合でも同一のSQLとして扱うようになります。

About me

  • I'm yaksa
  • From Tokyo, Japan
My profile
にほんブログ村 IT技術ブログへ

blogRanking