Help Center/ GaussDB/ Developer Guide(Centralized_V2.0-8.x)/ FAQ/ What is the maximum number of columns in a single GaussDB table?
Updated on 2025-06-27 GMT+08:00

What is the maximum number of columns in a single GaussDB table?

Answer: 1600. The value varies according to the column type. The column type is not verified during table creation but is verified during data storage. For example, for a column of the bigint type, each column stores 8-byte data. If there are 1600 columns, 12800 bytes need to be stored, which exceeds 8 KB on a page, and an error is reported during insertion.

If the data length of a column exceeds the maximum allowed, the data may be stored in a TOAST table. The logic is as follows:

  1. If the total length of a tuple exceeds 2 KB, the column containing the longest data is compressed first.
  2. Toast table storage is enabled only when the data length of a column exceeds the size limit after compression and is larger than the TOAST metadata overhead (24 bytes).
  3. A TOAST table stores the full data of each column, while the main table stores only query metadata.
  4. After compression, an error is reported if the total length of a single row exceeds the size of a single page (8 KB) regardless of whether a TOAST table is used. If a TOAST table is used, the main table stores its metadata; otherwise, it stores the compressed column data.