<@U04S8PLJWMT> how to create a postgres index with...
# ask-ai
f
@kapa.ai how to create a postgres index with airbyte?
k
Airbyte creates the necessary Postgres indexes automatically on the destination tables during syncs—you don’t manually create them in Airbyte’s UI. For Destination V2, Airbyte issues CREATE INDEX IF NOT EXISTS statements for internal columns like _airbyte_raw_id, _airbyte_extracted_at, and _airbyte_loaded_at as part of its table post-creation routine. [[destination-postgres](https://docs.airbyte.com/integrations/destinations/postgres); [Issue 61349](https://github.com/airbytehq/airbyte/issues/61349)] If you need custom indexes (e.g., on business columns), the knowledge sources don’t document a built-in way to define them via Airbyte. You’d create them directly in your Postgres database (outside Airbyte) after Airbyte has created/updated the tables. Note: Some users have observed duplicated internal indexes in certain scenarios, which can impact disk usage. [[Issue 61349](https://github.com/airbytehq/airbyte/issues/61349)] If your goal is to ensure Airbyte can create its own objects, the destination user must have permissions to create tables and schemas; lacking privileges will cause initialization errors. [[Postgres destination](https://docs.airbyte.com/integrations/destinations/postgres); [Issue 60244](https://github.com/airbytehq/airbyte/issues/60244)]
Short answer: Airbyte doesn’t offer a built-in way to define your own Postgres indexes in the connection/config. You’ll need to create indexes directly in your Postgres database (outside Airbyte). Airbyte may add a few internal indexes automatically on destination tables (e.g., _airbyte_extracted_at, _airbyte_raw_id, _airbyte_loaded_at), but it won’t recreate your source DB’s primary keys or custom indexes. [[Exact copy](https://discuss.airbyte.io/t/3918); [Internal indexes](https://github.com/airbytehq/airbyte/issues/61349)] How to add an index yourself (run in Postgres):
Copy code
sql -- Example: create an index on Airbyte’s extracted-at column CREATE INDEX IF NOT EXISTS your_table_extracted_at   ON your_schema.your_table (_airbyte_extracted_at);
This follows the same SQL shape Airbyte uses for its internal indexes. [[Internal indexes](https://github.com/airbytehq/airbyte/issues/61349)] Notes: - Ensure the Postgres user Airbyte writes with (or your DBA account) has privileges to create indexes/schemas. [[Postgres destination](https://docs.airbyte.com/integrations/destinations/postgres)] - If you need exact schema/index parity from source, you’ll have to manage it yourself or customize normalization/connector code. [[Exact copy](https://discuss.airbyte.io/t/3918)]
f
airbyte is deleting indexes on full sync again
@kapa.ai airbyte is deleting indexes on full sync again
k
A message from kapa.ai
Short answer: Yes, that can happen with Full Refresh – Overwrite, depending on the destination and whether normalization/dbt is involved. - In Full Refresh – Overwrite, certified database destinations commonly recreate the final table each sync by writing to a temp table, dropping the old table, then renaming the new one. When the table is dropped/recreated, indexes tied to that table are effectively removed and must be recreated. [[Full refresh overwrite](https://docs.airbyte.com/platform/using-airbyte/core-concepts/sync-modes/full-refresh-overwrite); [Full refresh overwrite 1.7](https://docs.airbyte.com/platform/1.7/using-airbyte/core-concepts/sync-modes/full-refresh-overwrite)] - Community reports show that related database objects (like views) can be dropped during full refresh/normalization runs, which aligns with the recreate/drop pattern. [[Remove related views](https://discuss.airbyte.io/t/747); [Table deleted/re-created](https://discuss.airbyte.io/t/1114)] - For Postgres specifically, Airbyte creates its own internal indexes on raw tables (e.g., _airbyte_raw_id, _airbyte_extracted_at, _airbyte_loaded_at) after creating tables. If a full refresh overwrite recreates tables, custom indexes you added on the final tables won’t persist unless you reapply them post-sync or manage them outside of Airbyte’s managed schemas. Note there are open issues about index behavior/duplication in destination-postgres. [[Issue 61349](https://github.com/airbytehq/airbyte/issues/61349)] If you need persistent custom indexes: - Apply them via your own post-sync job or manage them on views/materializations you control outside Airbyte’s managed tables. - Consider Incremental modes to avoid wholesale table recreation, which reduces the chance of losing indexes. [[Sync modes](https://docs.airbyte.com/platform/using-airbyte/core-concepts/sync-modes)]