LoginSignup
8
6

More than 5 years have passed since last update.

Postgresのカラム数と1レコードサイズの上限に関するメモ

Last updated at Posted at 2019-02-10

背景

Postgresを使った大量のカラムが必要なシステムがあり、Postgresのカラム数
制限(250~1600)を信じてテーブルを作ったがエラーが発生したのでメモ。

環境

  • Postgres11
  • 1テーブルあたりのカラム数 1500 (実際には数は数千になるがテーブル分割により対応)
  • カラム型 double precision
  • 言語 Pytnon(psycong2)

状況

この状況でcreate table は可能だったため、安心していたところ
データをinsertするときになって以下エラーが発生

psycopg2.OperationalError: row is too big: size 10728, maximum size 8160

原因

原因としては、1レコードサイズに8160バイトという制限がありそれを超えたため。
double precisionは、8バイトのため、8バイトx カラム数が8160バイト以下になる
ようカラム数を1000にしたところ解決。

8
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
6