Error: Tables Can Have at Most 1600 Columns
Issue
The sync fails with the following error:
ERROR: tables can have at most 1600 columns
The error persists even after excluding or blocking columns from syncs.
Environment
Resolution
Run the following query to determine whether dropped columns contribute to the column limit for the affected table. Replace
<schema>and<table>in the query with the actual schema and table names.SELECT COUNT(*) FILTER (WHERE NOT attisdropped) AS active_columns, COUNT(*) FILTER (WHERE attisdropped) AS dropped_columns, COUNT(*) AS total_columns FROM pg_attribute WHERE attrelid = '<schema>.<table>'::regclass AND attnum > 0;If
dropped_columnsis high andtotal_columnsis close to 1600, dropped columns are causing the issue.Depending on whether you want to preserve the existing destination data, choose one of the following options:
Recreate the table with only active columns. This option preserves the existing data by copying only active columns into a new table. Replace
<schema>and<table>in the query with your actual schema and table names.BEGIN; CREATE TABLE <schema>.<table>_new AS SELECT <col1>, <col2>, ... FROM <schema>.<table>; ALTER TABLE <schema>.<table> RENAME TO <table>_old; ALTER TABLE <schema>.<table>_new RENAME TO <table>; DROP TABLE <schema>.<table>_old; COMMIT;Drop the affected table and re-sync the table or connection. This option recreates the table and removes the existing table, including data in the dropped columns, from the destination.
DROP TABLE <schema>.<table>;
Cause
PostgreSQL counts dropped columns toward the 1600-column limit for each table. When Fivetran adds and removes many columns over time, the table can accumulate dropped column slots even though those columns no longer appear in the schema.
Blocking or excluding columns from your syncs only stops Fivetran from writing new data to those columns. Blocking or removing columns does not remove the dropped column slots from the destination table. As a result, PostgreSQL can still reach the 1600-column limit even when the number of active columns is low.