« Command-Period | トップページ | いろいろと面倒くさい大人の事情縛りのOracleパフォーマンスチューニング #2 »

2011年7月 6日 (水) / Author : Hiroshi Sekiguchi.

いろいろと面倒くさい大人の事情縛りのOracleパフォーマンスチューニング #1

どこかで聞いたことありそうなタイトルを少々パクリつつ、まずは準備運動から…

ということで、今回は、そのパーティショニングタイプ選択ミスってないか? 
ってところから始めていくつかイケてなかったクエリを、パーティショニングタイプの選択ミスはミスだが、どーしても今は変更できな〜い。
という大人の事情(どんな大人だw) に金縛りな状況でSQLチューニングしてみましょ。というネタ :)

以下のような3表を作成してあります。 (nologgingなのは気にしないでね)

列定義は同じですが、非パーティション表で主キーあり、ハッシュパーティション表で主キーはグローバル索引、月単位のレンジパーティション表で主キーはローカル索引の3表。
各店舗(1300店)での売上げを品目(140品目)毎、かつ日毎に集計したデータが1年分(365日分)登録されていると思ってください。
(思わなくてもいいですけど、登録してありますw)

create table test1
(
starting_date char(8) not null,
shop_code char(4) not null,
sales_figure number not null,
item_code char(10) not null,
constraint pk_test1 primary key (starting_date,item_code,shop_code) using index tablespace tsimax nologging
)
tablespace tsmax
nologging
/

create table test2
(
starting_date char(8) not null,
shop_code char(4) not null,
sales_figure number not null,
item_code char(10) not null,
constraint pk_test2 primary key (starting_date,item_code,shop_code) using index global tablespace tsimax nologging
)
partition by hash(starting_date)
(
partition test201 tablespace ts001,
partition test202 tablespace ts002,
partition test203 tablespace ts003,
partition test204 tablespace ts004
)
nologging
/

create table test3
(
starting_date char(8) not null,
shop_code char(4) not null,
sales_figure number not null,
item_code char(10) not null,
constraint pk_test3 primary key (starting_date,item_code,shop_code) using index local
(
partition test301idx tablespace tsi001,
partition test302idx tablespace tsi002,
partition test303idx tablespace tsi003,
partition test304idx tablespace tsi004,
partition test305idx tablespace tsi001,
partition test306idx tablespace tsi002,
partition test307idx tablespace tsi003,
partition test308idx tablespace tsi004,
partition test309idx tablespace tsi001,
partition test310idx tablespace tsi002,
partition test311idx tablespace tsi003,
partition test312idx tablespace tsi004,
partition testmaxidx tablespace tsimax
)
nologging
)
partition by range(starting_date) (
partition test301 values less than ('20110201') tablespace ts001,
partition test302 values less than ('20110301') tablespace ts002,
partition test303 values less than ('20110401') tablespace ts003,
partition test304 values less than ('20110501') tablespace ts004,
partition test305 values less than ('20110601') tablespace ts001,
partition test306 values less than ('20110701') tablespace ts002,
partition test307 values less than ('20110801') tablespace ts003,
partition test308 values less than ('20110901') tablespace ts004,
partition test309 values less than ('20111001') tablespace ts001,
partition test310 values less than ('20111101') tablespace ts002,
partition test311 values less than ('20111201') tablespace ts003,
partition test312 values less than ('20120101') tablespace ts004,
partition testmax values less than (maxvalue) tablespace tsmax
)
nologging
/


次回へつづく。

| |

トラックバック


この記事へのトラックバック一覧です: いろいろと面倒くさい大人の事情縛りのOracleパフォーマンスチューニング #1:

コメント

コメントを書く