[pgsql-jp: 30122] Re: データファイルの分断化までのサイズについて

sugita @ sra.co.jp sugita @ sra.co.jp
2003年 6月 3日 (火) 17:14:23 JST


  杉田です。

From: "Iso, Toshitaka" <toshitaka.iso @ hp.com>
Subject: [pgsql-jp: 30121] データファイルの分断化までのサイズについて
Date: Tue, 3 Jun 2003 16:40:17 +0900

;;; データファイルの分断化についてお教え下さい。
;;; 
;;; OS=Redhat 7.2
;;; DB=PostgreSQL 7.2.1
;;; 
;;; contribのoid2nameコマンドで論理名称からOIDに変換してテーブル単位の
;;; ファイルを見たところ、レコード件数の大きい(1800万件)のテーブルが以下のよ
;;; うに5ファイルに分裂しておりました。
;;; 
;;; -rw-------    1 postgres postgres 1073741824  6月  3 16:22 293309896
;;; -rw-------    1 postgres postgres 1073741824  6月  3 16:22 293309896.1
;;; -rw-------    1 postgres postgres 1073741824  6月  3 16:32 293309896.2
;;; -rw-------    1 postgres postgres 1073741824  6月  3 16:22 293309896.3
;;; -rw-------    1 postgres postgres 634208256  6月  3 16:32 293309896.4
;;; 
;;; 見た限り1GBを超えたものは「データファイル.n」という感じにインクリメントされている
;;; ようですが、

  PostgreSQL 7.2.1 ならば、contrib pg_controldata をインストールすると以下の 
Database block size * Blocks per segment of large relation がこの分割サイズで
す。この実行は、PostgreSQL 7.3 なので、他の項目が少し PostgreSQL 7.2 とは違い
ます。

    $ pg_controldata 
    pg_control version number:            72
    Catalog version number:               200211021
    Database cluster state:               in production
    pg_control last modified:             Tue Jun  3 10:29:50 2003
    Current log file ID:                  0
    Next log file segment:                8
    Latest checkpoint location:           0/7DE6FE8
    Prior checkpoint location:            0/7DD2488
    Latest checkpoint's REDO location:    0/7DE6FE8
    Latest checkpoint's UNDO location:    0/0
    Latest checkpoint's StartUpID:        33
    Latest checkpoint's NextXID:          17206
    Latest checkpoint's NextOID:          598877
    Time of latest checkpoint:            Tue Jun  3 10:29:48 2003
=>  Database block size:                  8192
=>  Blocks per segment of large relation: 131072
    Maximum length of identifiers:        64
    Maximum number of function arguments: 32
    Date/time type storage:               64-bit integers
    Maximum length of locale name:        128
    LC_COLLATE:                           C
    LC_CTYPE:                             C
    $ 

;;; 		これをLinuxのファイルサイズ限界(2GB?)の1.8GBくらいになって初めて
;;; 分断化されるように設定は出来ないのでしょうか。。
;;; 
;;; それともこの1GBでファイルの分断化が起こるのはPostgreSQLにとって最適な
;;; ものなんでしょうか?
;;; 
;;; もし設定が可能であれば設定指標をお教えいただけたら幸いです。

  設定の変更と指標は、以下の通りです。

    ====  src/include/pg_config.h  ====
    /*
     * RELSEG_SIZE is the maximum number of blocks allowed in one disk file.
     * Thus, the maximum size of a single file is RELSEG_SIZE * BLCKSZ;
     * relations bigger than that are divided into multiple files.
     *
     * CAUTION: RELSEG_SIZE * BLCKSZ must be less than your OS' limit on file
     * size.  This is typically 2Gb or 4Gb in a 32-bit operating system.  By
     * default, we make the limit 1Gb to avoid any possible integer-overflow
     * problems within the OS.  A limit smaller than necessary only means we
     * divide a large relation into more chunks than necessary, so it seems
     * best to err in the direction of a small limit.  (Besides, a power-of-2
     * value saves a few cycles in md.c.)
     *
     * CAUTION: changing RELSEG_SIZE requires an initdb.
     */
    #define RELSEG_SIZE     (0x40000000 / BLCKSZ)

  大きくされたいという事からの連想ですが、仮にレコードサイズが大きいとしたなら
ば、デフォルトの Database block size = 8192 で、ブロッキングファクタが適してい
るかを pg_filedump ないし ctid を調べて、ブロックサイズを大きくするようにする
ことも検討されても良いかも知れません。場合によっては、1 ブロックに 1 レコード
で、ページの半分しか領域が使われないという最悪な場合も有ります。


Kenji Sugita                                      



pgsql-jp メーリングリストの案内