[pgsql-jp: 35967] Re: VACUUM中にCOPYが終わらない
ISHIDA Akio
iakio @ mono-space.net
2005年 9月 7日 (水) 19:57:06 JST
こんにちは。石田@苫小牧市です。
Kazuo Kojima wrote:
> 小島と申します。
(中略)
> その際にPSQLコマンドでpg_locksを発行した際に取得した情報を以下に
> 記載します。
> 以前、このメーリングリストで見つけたコマンドを使用しました。
>
> mstp_db=# select l.pid,c.relname,l.transaction,l.mode,l.granted from
> pg_locks l LEFT OUTER JOIN pg_
> class c ON l.relation = c.oid;
> pid | relname | transaction | mode |
> granted
> ----+---------------+----------+------------------+---------
> 572 | | 1688237 | ExclusiveLock | t
> 2388 | tbl_a | |
> ShareUpdateExclusiveLock | t
> 572| tbl_b | | AccessShareLock | t
> 572| tbl_a | | RowExclusiveLock | t
> 2388| tbl_a | |
> ShareUpdateExclusiveLock | t
> 2388| | 1678055 | ExclusiveLock | t
これを見るかぎり、ロックが競合しているようには見えません。
(grantedがすべて't'だからです)
単純に処理に時間がかかっていると仮定して、
1. 他の方もおっしゃっていますが、全件削除をするのであれば、
truncateを使いましょう。
2. 他の方もおっしゃっていますが、可能であればインデックスを
削除してからcopyしましょう。この場合はprimary keyなので
alter table ... drop constraint ですが。
3. numeric(2.0)などは、可能であればint4などにしましょう。
それだけでもかなり違うと思います。
> テーブル情報
> Column | Type | Modifiers
> -----------+-------------------+-----------
> item01 | numeric(2,0) | not null
> item02 | numeric(10,0) | not null
> itea03 | character varying(3) | not null
> item04 | numeric(4,0) | not null
> item05 | numeric(4,0) | not null
> item06 | numeric(10,0) |
> item07 | numeric(3,0) |
> item08 | numeric(10,0) |
> item09 | numeric(3,0) |
> item10 | numeric(5,0) | not null
> item11 | timestamp without time zone | not null
> Indexes:
> "tbl_a_key" primary key, btree (item01, item02, item03, item04,
> item05, item11)
--
ISHIDA Akio <iakio @ mono-space.net / ishida @ cycleof5th.com>
pgsql-jp メーリングリストの案内