第3回 PostgreSQLを遅くしている犯人はどこだ?

下垣徹
NTT OSSセンタ
2008/6/9

今回取り上げるSQLがアクセスしている各テーブルの定義

■customerテーブル

DBT1=# \d+ customer
Table "public.customer"
Column |      Type      | Modifiers | Description
----------+--------------------------+-----------+-------------
c_id    | integer           | not null  |
c_uname   | character varying(20)    |           |
c_passwd  | character varying(20)    |           |
c_fname   | character varying(15)    |           |
c_lname   | character varying(15)    |           |
c_addr_id | integer                  |           |
c_phone   | character varying(16)    |           |
c_email   | character varying(50)    |           |
c_since   | date                     |           |
c_last_visit| date                   |           |
c_login   | timestamp without time zone |        |
c_expiration | timestamp without time zone |     |
c_discount| numeric(5,2)             |           |
c_balance | numeric(17,2)            |           |
c_ytd_pmt | numeric(17,2)            |           |
c_birthdate | date                   |           |
c_data    | character varying(500)   |           |
Indexes:
    "customer_pkey" PRIMARY KEY, btree (c_id)
    "i_c_birtdate" btree (c_birthdate)
    "i_c_uname" btree (c_uname)
Has OIDs: no
customerテーブルの定義

ordersテーブル

DBT1=# \d+ orders
          Table "public.orders"
  Column    |         Type            | Modifiers | Description
------------+-------------------------+-----------+-------------
o_id        | integer                 | not null  |
o_c_id      | integer                 |           |
o_date      | timestamp without time zone |       |
o_sub_total | numeric(17,2)           |           |
o_tax       | numeric(17,2)           |           |
o_total     | numeric(17,2)           |           |
o_ship_type | character varying(10)   |           |
o_ship_date | timestamp without time zone |       |
o_bill_addr_id | integer              |           |
o_ship_addr_id | integer              |           |
o_status | character varying(15)      |           |
Indexes:
"orders_pkey" PRIMARY KEY, btree (o_id)
"i_o_c_id" btree (o_c_id)
Has OIDs: no
ordersテーブルの定義

cc_xactsテーブル

DBT1=# \d+ cc_xacts
Table "public.cc_xacts"
   Column   |         Type            | Modifiers | Description
------------+-------------------------+-----------+-------------
cx_o_id     | integer                 | not null  |
cx_type     | character varying(10)   |           |
cx_num      | bigint                  |           |
cx_name     | character varying(31)   |           |
cx_expiry   | date                    |           |
cx_auth_id  | character(15)           |           |
cx_xact_amt | numeric(17,2)           |           |
cx_xact_date| timestamp without time zone |       |
cx_co_id    | smallint                |           |
Indexes:
     "cc_xacts_pkey" PRIMARY KEY, btree (cx_o_id)
Has OIDs: no
cc_xactsテーブルテーブルの定義

 

Index
Linuxトラブルシューティング探偵団
 第3回 PostgreSQLを遅くしている犯人はどこだ?
Page 1
 今回の相手はPostgreSQLの性能
 で、そもそもチューニングって何なのさ?
  Page 2
 性能問題の原因を探る2つのステップ
 どのSQLが遅いのか?
  そのSQLのどこに時間がかかっているのか?
 コラム 実行計画が最適かどうかをチェック
  Page 3
 出力内容を追いかけろ
 こんなに時間がかかる理由は?
 いざ、絞り込んで問題の解決へ
 常に考えをめぐらせながら解決を



Linux & OSS フォーラム 新着記事
@ITメールマガジン 新着情報やスタッフのコラムがメールで届きます(無料)

注目のテーマ

Linux & OSS 記事ランキング

本日 月間