DHJJ [Hatsune's Journal Japan] blog

Hatsune's Journal Japan blog

目次

Blog 利用状況

ニュース

最新ツイート

運営サイト

Hatsune's Journal Japan
DHJJ

著作など

資格など

OCP
MCP

書庫

日記カテゴリ

わんくま同盟

最適化してくれないDB2の最適化処理(解決編)

最適化してくれないDB2の最適化処理(解決編)

http://blogs.wankuma.com/hatsune/archive/2007/09/20/97109.aspx

上記エントリで報告をした問題ですが、その後、解決をしておりますので報告します。

問題が発生する例:

  • 主キーが(日付、通番)
  • データ分布として、[日付]値が2~3日くらい
  • DB2の最適化を動かしている
  • ⇒実行プランがTABLE SCAN

問題回避の例:

  • 主キーが(通番、日付)
  • データ分布として、[日付]値が2~3日くらい
  • DB2の最適化を動かしている
  • ⇒実行プランがINDEX SCAN

つまり、主キーの第一項目のカーディナリティ度が低いとINDEX SCANではなくTABLE SCANが行われるようなのです。

確かに、B-Treeインデックスはカーディナリティ度が高い場合に効果が高いですが、低いからといってTABLE SCANが良いとは限りません。実際、データを入れた直後で最適化を動かしていないときの実行プランはINDEX SCANで最適化を動かしてTABLE SCANになったら実行時間が10倍になるという測定結果も得ていました。

このような問題は、問題回避の例にあるようにプログラムコードを一切変えずにDB側の主キー変更のみで本来想定していた動きになり、無事稼動しております。

この問題解決はDB管理者とアプリ開発者が一致団結して問題解決にあたった成果であり、DB管理者が「アプリのつくりが悪い」、アプリ開発者が「いや、コードに悪いところは見当たらない」などと言っているようでは解決に至らなかったと思います。

DB管理者(というかDB設計)とアプリ開発との両方に関わる事が最近は多かったのですが、久々にDB管理者(DB設計者)が管轄外にいるプロジェクトでしたが、敵対するのではなく協調する事が大切だと再認識させられました。

投稿日時 : 2008年3月31日 15:34

Feedback

# re: 最適化してくれないDB2の最適化処理(解決編) 2008/08/22 10:25 DB2を使っている者として一言

主キーの列順を入れ替えた→結果的に索引の列順が入れ替わった

と読み取りましたが、要は索引の作り方の問題なのでは無いかと思いました。DB2はV8からは相当Optimizerも賢くきちんと設計して統計情報を取得すれば、よほどのことが無い限り変なアクセスパスを選択することは無いです。

今後同じようなことが起きた場合、一度以下のものを使ってみる事をオススメします。指定したSQLを実行するにあたりこんな索引を作ると良いよ、とアドバイスしてくれます。統計情報に基づきアドバイスしてくれるので、きちんと本番時を模擬したデータを入れてRUNSTATSをかけた状態で使ってみてください。

【設計アドバイザー】
http://www-06.ibm.com/jp/software/data/developer/library/techdoc/kantandb2.html

# DB2は果たして本当にそうなのでしょうか。 2008/08/24 1:59 はつね

http://blogs.wankuma.com/hatsune/archive/2008/08/22/154031.aspx

# mulberry outlet 2012/11/17 16:21 http://www.mulberryoutlethandbagsshopuk.co.uk/

Virtually no individual may be worth an individual's holes, and therefore the a person that is definitely North Korean won‘capital t allow you to scream.
mulberry outlet http://www.mulberryoutlethandbagsshopuk.co.uk/

# louis vuitton outlet 2012/11/18 23:35 http://www.louisvuittonbackpack2013.com/

Because one doesn‘testosterone accept you and the choice of would like them with,doesn‘testosterone signify these folks preceptor‘testosterone accept you boost they offer.
louis vuitton outlet http://www.louisvuittonbackpack2013.com/

# nike free 3.0 v3 2012/11/19 14:20 http://www.nikeschuhedamenherren.com/nike-free-30-

Happen to be go on as soon as per companion thinks he's a small high quality beyond the other useful.
nike free 3.0 v3 http://www.nikeschuhedamenherren.com/nike-free-30-v3-damen-running-schuhe-blau-weiß-p-1021.html/

# nike pas cher 2013/01/10 15:59 http://www.robenuk.eu/

Don't consult your ultimate pleasure to one much lucky as your own.
nike pas cher http://www.robenuk.eu/

# destockchine 2013/01/11 22:37 http://www.destockchinefr.fr/nike-shox-pas-cher/ni

Happiness can be a parfum that people plastic bottles to a number of people not including achieving a not many declines to on your own.
destockchine http://www.destockchinefr.fr/nike-shox-pas-cher/nike-shox-nz-2-pas-cher/

# destockchine 2013/03/03 6:14 http://www.c55.fr/

A good solid honestly might anyone, except anyone are invariably a good honestly. destockchine http://www.c55.fr/

# sarenzalando 2013/03/03 6:14 http://www.ckguccifr.fr/

Say you decided to would most likely learn how to blueprint received from an opponent, enlighten getting this done to never a person. sarenzalando http://www.ckguccifr.fr/

# Air Jordan Retro 3 2013/03/07 18:38 http://www.jordanretro3air.com/

A pal that you simply simply decide to buy together with shows is purchased in anyone. Air Jordan Retro 3 http://www.jordanretro3air.com/

# destockchine 2013/03/07 18:40 http://www.b77.fr/chaussure-femme-c-4.html/

If you wish any human resources of this worthy of, add up your. destockchine http://www.b77.fr/chaussure-femme-c-4.html/

# destock chine 2013/03/07 18:41 http://www.c55.fr/

All the most awful ways to pass up person has to be laying ideal invariably the group once you learn you could potentially‘t get them. destock chine http://www.c55.fr/

# Air Jordan Retro 3 2013/03/07 18:45 http://www.jordanretro3air.com/

Cheer is mostly a aromatise you wonrrrt afin de upon other individuals without ending up with a limited reduces upon all by yourself. Air Jordan Retro 3 http://www.jordanretro3air.com/

# casquette supreme 2013/03/15 20:52 http://www.b44.fr/

With successfulness our own mates learn all of us; at difficulty can certainly our own mates. casquette supreme http://www.b44.fr/

# casquette armani 2013/03/23 6:04 http://f55.fr/

Never individual may be your own weeping, as well a person that is certainly acquired‘d force you yowl. casquette armani http://f55.fr/

# brandalley 2013/04/07 0:54 http://rueree.com/

Really don't connect with others whorrr re more comfortable to be with. To understand which will enforce you to ultimately pry your business upwards. brandalley http://rueree.com/

# cc 2018/06/30 8:45 chenlixiang

http://www.mulberryhandbagsoutlet.org.uk
http://www.oakleysunglassesuk.me.uk
http://www.nike-free-run.fr
http://www.nikefree-run.co.uk
http://www.michael--kors.fr
http://www.celine-handbags.org
http://www.truereligionjeansoutlet.us.com
http://www.portugalworldcupjersey.com
http://www.abercrombieoutlet.us.org
http://www.airmax2018.us.org
2018.6.30chenlixiang

タイトル
名前
Url
コメント