A PostgreSQL table can hold at most 1,600 columns, and etlmcp adds two columns for every Meta action type it sees. When many Meta ad accounts, each with its own custom conversions, load into one table, the table eventually reaches that cap, and from then on every run fails with database error: tables can have at most 1600 columns. Dropping columns does not bring the table back under the cap. The way out is a new table: one per client is the usual split, with a select rule that keeps only the extras you report on.
Where the columns come from
etlmcp writes a fixed set of common columns, such as date, campaign_name, cost and conversions. Anything a platform reports beyond those is an extra, and it lands in a column named extra.<key>. When a load brings an extra the table does not have yet, etlmcp runs an ALTER TABLE … ADD COLUMN for it before inserting the rows. It never drops a column, so the table only grows.
When the Meta connector is available, each entry in Meta's actions and action_values lists becomes a field of the row. A type such as lead turns into two columns, extra.actions.lead for the count and extra.action_values.lead for the value. See Meta's action columns for how to read them.
Meta's Ads Action Stats reference lists custom conversions as their own action type, offsite_conversion.custom.<id>, where the id is the custom conversion's own id. Meta's conversion tracking page sets the limit at 100 custom conversions per ad account. So one account can add up to 200 columns from custom conversions alone, on top of the standard action types. Ten client accounts with full custom conversion lists can pass 1,600 by themselves, because each account's ids are different.
What PostgreSQL counts
PostgreSQL's limits appendix gives three rules that matter here:
- A table has at most 1,600 columns.
- Columns you have dropped still count toward that cap, and they still take space in each new row's null bitmap.
- A row must also fit in one 8,192-byte heap page. etlmcp stores action counts and values as
double precision, which take 8 bytes each, so a table of mostly numeric extras can reach the page limit before it reaches 1,600 columns.
The error text comes from PostgreSQL itself. Its source raises tables can have at most 1600 columns when an ALTER TABLE would add a column past the cap. etlmcp passes the first line of the database's message on, prefixed with database error:, so that is what the failed run shows.
Why dropping columns does not help
Because dropped columns keep counting, running ALTER TABLE … DROP COLUMN on unused extra.actions.* columns frees no room. The next load that brings a new custom conversion tries to add a column and fails the same way. Rebuilding the table, for example with CREATE TABLE … AS SELECT into a fresh table, does reset the count, but etlmcp only writes to a table it created itself (it marks its tables with a _etlmcp_pipeline_id column), so a hand-built copy is refused. Let etlmcp create the new table.
The fix
- Point each client's pipelines at their own table. Set a new table name on the PostgreSQL destination, or add a destination per client; etlmcp creates the table on the first run. Destinations count toward your plan's destination allowance, as the plans list.
- Add a select rule to the pipeline's transform, naming the common columns you need and only the extras you report on, such as
extra.actions.leadandextra.action_values.offsite_conversion.custom.<id>. Columns you leave out of the select never reach the table, so they never add a column. See transforms. - Point your reports at the new tables, or join them with a view.
Do this before a table nears the cap. Counting the columns now (SELECT count(*) FROM information_schema.columns WHERE table_name = '<your table>') tells you how close you are, though it does not show dropped columns that still count.
For other load failures on this destination, see PostgreSQL destination errors.