Hi all , Can someone help me with this?? Question:...
# replication-troubleshooting
s
Hi all , Can someone help me with this?? Question: I’m using Airbyte in a tenant-based setup where each user connects their LinkedIn Ads account as a source, and my destination is Postgres. The problem is that for every new user, Airbyte creates a new table in Postgres — and since each stream also creates a table, I end up with thousands of tables. This design doesn’t feel scalable. What I’d like instead is: A single (or at least fewer) tables in Postgres for all users. Ideally, a way to include a user_id or account_id column to separate data from different users/accounts, instead of separate tables. Has anyone found a good workaround or best practice for consolidating Airbyte’s output into fewer tables in Postgres?
k
Short answer: Airbyte doesn’t currently support mapping many source streams into a single destination table or auto-adding a “tenant” column. This is a known limitation and a requested feature ([issue #2224](https://github.com/airbytehq/airbyte/issues/2224)). Today, each stream maps to its own destination table, so many tenants and many streams lead to many tables. Workarounds and practices seen in the community: - Use separate namespaces per tenant, then unify via views - Write each tenant to its own schema/namespace (using destination namespace options), then create a Postgres view that UNION ALLs the per-tenant tables and injects a tenant identifier. This avoids table-name collisions and keeps operational isolation, while giving you a single logical view to query (community guidance given for BigQuery, but the pattern applies similarly to Postgres) ([Support for Multi Tenancy](https://discuss.airbyte.io/t/411)). - Avoid concurrent writes to the same final tables from multiple connections - When multiple connections write to the same destination tables, temp/staging structures can collide. The recommended mitigations are separate namespaces or ensuring only one sync runs at a time (set a single worker) to avoid concurrency issues ([Multiple source sync to same destination table](https://discuss.airbyte.io/t/1105)). - Use per-connection prefixes and downstream dbt to consolidate - Keep separate connections (and thus separate final tables) but add table prefixes per connection, then use a dbt (or SQL) model to UNION ALL into a consolidated table and add a data_source/user_id column. This was suggested as a clean approach when aggregating multiple sources of the same schema ([Manage multiple sources sync to the same tables](https://discuss.airbyte.io/t/323)). - Direct mapping to arbitrary target table names isn’t supported - You can’t set a different target table name per stream within a single destination to merge many streams into one table today ([Postgres-destination: specify target table](https://discuss.airbyte.io/t/2728); [issue #2224](https://github.com/airbytehq/airbyte/issues/2224)). Notes specific to LinkedIn Ads: - You can scope which accounts to pull via Account IDs, and define custom analytics streams, but table-per-stream behavior remains the same ([LinkedIn Ads setup](https://docs.airbyte.com/integrations/sources/linkedin-ads#step-2-set-up-the-linkedin-ads-connector-in-airbyte); [LinkedIn Ads migration guide](https://docs.airbyte.com/integrations/sources/linkedin-ads-migrations)). Given today’s capabilities, the most robust pattern in Postgres is: - Use one schema per tenant (or per connection) to avoid collisions. - Build a consolidated table or view that UNION ALLs tenant tables and adds a tenant/user_id column. - Optionally enforce one-sync-at-a-time if you must write into shared structures to avoid temp-table collisions ([Multiple source sync to same destination table](https://discuss.airbyte.io/t/1105)). - Track the feature request for merging multiple streams into a single table to reduce table sprawl ([issue #2224](https://github.com/airbytehq/airbyte/issues/2224)).