> ## Documentation Index
> Fetch the complete documentation index at: https://docs.prequel.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Physical replication

> Replicate Iceberg tables by copying data files directly, without reading or rewriting rows

> [!WARNING]
>
> **Physical replication is in beta**
>
> Physical replication is currently in beta. Contact the Prequel team to enable it for your account.

![](https://storage.googleapis.com/prequel_docs/images/prequel-physical-vs-logical-replication.png "Physical replication copies the recipient's data files and commits matching Iceberg metadata, without reading or rewriting rows.")

## Overview

By default, Prequel queries rows from your source and writes them to the destination. This page calls that logical replication. Physical replication instead copies an Apache Iceberg table's data files to the recipient's bucket and commits matching Iceberg metadata. Rows are never queried or rewritten, so throughput depends on how fast files can be copied between buckets.

Because files are copied as-is, every column keeps its source type, including decimal precision and scale. This also delivers types that logical replication does not support, such as string arrays.

> [card] Higher throughput
>
> On some of Prequel's highest-volume workloads, table-level throughput improved by 9x.

> [card] No queries against your source
>
> Prequel reads files from your catalog and bucket, so transfers put no query load on a warehouse.

> [card] Hard deletes are propagated
>
> Rows deleted from the source table are removed from each recipient's copy on the next transfer.

> [card] Open format for recipients
>
> Recipients get a standard Iceberg table they can query from Snowflake, BigQuery, Athena, and other engines.

For background on the design, read [Building table-aware, partition-aware physical replication for Iceberg tables](https://prequel.co/blog/physical-replication-for-iceberg-tables).

## Comparing logical vs physical replication

| |  Logical replication (default) |  Physical replication |
| - | - | - |
| Sources | All [supported sources](https://docs.prequel.co/export/sources/overview.md) | [Apache Iceberg](https://docs.prequel.co/export/sources/iceberg.md) |
| Destinations | All [supported destinations](https://docs.prequel.co/export/destinations/overview.md) | [Apache Iceberg](https://docs.prequel.co/export/destinations/iceberg.md) |
| Unit of work | Rows | Data files |
| Throughput | Limited by how fast rows can be queried from the source and written to the destination | Limited by how fast files can be copied between buckets. 9x higher on some of Prequel's highest-volume workloads |
| Best for | Most tables, with any source and destination | High volume workloads over Iceberg-compatible destinations |
| Tenant filtering | Row filter on the organization column | Partition filter on the organization column |

## How physical replication in Prequel works

Each transfer of a physically replicated model runs the following steps:

1. **Read the table metadata.** Prequel reads the source table's current snapshot (its latest version) from your Iceberg catalog. The snapshot lists every data file and delete file in the table.
2. **Filter by recipient.** Prequel keeps only the files in partitions that belong to the recipient. Files in other recipients' partitions are never copied.
3. **Copy new files.** Prequel copies the files that the destination does not already have. On incremental transfers, files copied by earlier transfers are skipped.
4. **Commit to the destination.** Prequel updates the Iceberg metadata to point at the destination bucket and commits it to the destination catalog as a new snapshot. Recipients see the new data all at once, after the commit succeeds.

## Requirements

* The model's source is an [Apache Iceberg source](https://docs.prequel.co/export/sources/iceberg.md), and the destination is an [Apache Iceberg destination](https://docs.prequel.co/export/destinations/iceberg.md).
* `otf_acceleration_enabled` is set to `true` on both the model and the destination. A model with physical replication enabled can only be transferred to destinations that also have it enabled.
* The model reads from a `source_table` that is an Iceberg table. Views are not supported.
* The model still defines `columns`, including a primary key column and a last-modified column, like any other [model](https://docs.prequel.co/export/concepts/models.md#required-columns). Prequel checks that the model is well-formed, but does not validate it against the source table. The `columns` list does not control which columns are delivered. See [Limitations](#limitations).
* [Multi-tenant](https://docs.prequel.co/export/concepts/multi-tenancy.md) source tables are partitioned by the model's `organization_column`. See [Limitations](#limitations).

## How to enable physical replication

Physical replication uses the same [sources](https://docs.prequel.co/export/concepts/sources.md), [models](https://docs.prequel.co/export/concepts/models.md), [products](https://docs.prequel.co/export/concepts/products.md), [recipients](https://docs.prequel.co/export/concepts/recipients.md), and [destinations](https://docs.prequel.co/export/concepts/destinations.md) as any other transfer. You enable it with one setting on the model and one on the destination, both set through the API.

**1. Connect your Iceberg source**

Add your Iceberg catalog as a source by following the [Apache Iceberg source guide](https://docs.prequel.co/export/sources/iceberg.md).

**2. Prepare the source table**

Confirm the table is partitioned by your organization column. Then compact the recipient's partitions in your query engine so that they have no delete files before the first transfer. See [Do I need to compact the source table?](#faq)

**3. Check your existing destinations**

Make sure no recipient subscribed to the `all` product has a destination without physical replication that uses `"enabled_models": ["*"]` (**All current and future models** in the Prequel UI). Update those destinations to an explicit list of models first. Otherwise, the model in the next step cannot be created. See [Guardrails](#guardrails).

**4. Create the model**

Create a [model](https://docs.prequel.co/export/concepts/models.md) that reads from the table with `source_table`, and set `otf_acceleration_enabled` to `true`. Use the [Create model](https://docs.prequel.co/export/api-reference/models/create-model.md) endpoint.

If a model for this table already exists, create the new model alongside it with a different `model_name`. Two models that reach the same recipient cannot write to the same table name.

```json title="Physically replicated model" icon="brackets-curly" expandable theme={null}
{
  "model_name": "events",
  "columns": ["..."],

  "otf_acceleration_enabled": true,

  "source_table": "analytics.events",
  "source_name": "Example Iceberg Source",
  "organization_column": "organization_id"
}
```

**5. Create the destination**

Create the recipient's [Apache Iceberg destination](https://docs.prequel.co/export/destinations/iceberg.md) with `otf_acceleration_enabled` set to `true` using the [Create destination](https://docs.prequel.co/export/api-reference/destinations/create-destination.md) endpoint.

To migrate an existing recipient, add this as a second destination on the same recipient and run it in parallel with their current destination. The current destination must not use `"enabled_models": ["*"]`. See [Guardrails](#guardrails).

**6. Add the model to a product and transfer**

Add the model to a product assigned to the recipient. Transfers then run on the destination's schedule, or you can trigger one through the API as usual.

> [!NOTE]
>
> **Physical replication is set at creation**
>
> `otf_acceleration_enabled` cannot be changed after a model or destination is created. To move an existing model or destination to physical replication, create a new one with the setting enabled.

## Supported catalogs and query engines

### Sources

Prequel reads source tables from the catalogs supported by the [Apache Iceberg source](https://docs.prequel.co/export/sources/iceberg.md):

* AWS Glue Catalog
* AWS S3 Tables Catalog
* Iceberg REST Catalog

### Destinations

Each recipient receives an Iceberg table in their own bucket and catalog, using any catalog supported by the [Apache Iceberg destination](https://docs.prequel.co/export/destinations/iceberg.md). Recipients can query the delivered table from any query engine or system that reads Iceberg tables from that catalog, for example [Amazon Athena, Amazon Redshift, Snowflake, BigQuery, ClickHouse, DuckDB, MotherDuck, and Spark](https://docs.prequel.co/export/destinations/iceberg.md#mounting/reading-an-iceberg-table).

## Limitations

> [!WARNING]
>
> **Some Prequel features are not supported**
>
> Physical replication copies files in-place, so some Prequel features that depend on Prequel reading or rewriting rows are not supported.

* Every column in the source table is delivered, with its source name and type. The model's `columns` list, `name_in_destination` values, and `data_type` values are not applied.
  * What this means: do not enable physical replication on a table that contains columns you do not want to share.
* The source table must be partitioned by your organization column. Prequel copies only the files in partitions where the model's `organization_column` matches the recipient.
  * What this means: partition the table directly on that column (an identity partition) before enabling physical replication. A file is copied only when its partition value exactly equals the recipient's `id_in_provider_system`.
  * Files that Prequel cannot match to the recipient are never copied. This is intentional, so that a table with missing or incorrect partitioning cannot expose one recipient's data to another. In that case, transfers succeed but deliver no rows.
* A recipient's partitions must have no delete files before a model's first transfer to that recipient's destination and before any full refresh. Those transfers fail otherwise. Delete files in other recipients' partitions do not affect the transfer.
  * What this means: compact the recipient's partitions in your query engine first. You do not need to compact the whole table to add a new recipient. See [Do I need to compact the source table?](#faq)
* Source queries are not supported.
* Windowed transfers are not supported.
* Row filters are not supported. Recipients are separated only by partition, and Prequel does not filter rows within a data file.
* Partition evolution is not supported. Data files written before the table was partitioned by your organization column are not delivered.

## Guardrails

To ensure a model with physical replication enabled is never sent to an incompatible destination, Prequel enforces the following:

* Physical replication cannot be enabled or disabled on an existing model or destination. New resources are strictly required and the field is immutable after creation.
* A model with physical replication enabled can only be transferred to a destination that also has physical replication enabled.
* You cannot use `"enabled_models": ["*"]` (**All current and future models** in the Prequel UI) on a destination without physical replication if its recipient's products include a model with physical replication enabled. This applies to every recipient subscribed to the `all` product.
  * What this means: before enabling physical replication for a customer, ensure their current destinations are not using `"enabled_models": ["*"]`, and update them if they are.
  * While any recipient subscribed to the `all` product has such a destination, new models with physical replication enabled cannot be created. This check covers every recipient in your account, not only the customer you are enabling.

## FAQ

> [accordion] Does physical replication use the same recipients, products, and transfers as logical replication?
>
> Yes. A physically replicated model is assigned to recipients through products like any other model, and it runs in the same scheduled and manually triggered transfers. Transfers appear in the same API responses and webhooks, including the number of rows transferred.

> [accordion] Are full refreshes supported?
>
> Yes. You can run a [full refresh](https://docs.prequel.co/export/concepts/transfers.md#backfills-&-full-refreshes) on a model with physical replication enabled the same way as on any other model. Compact the recipient's partitions first so that they have no delete files, as described below.
>
> The other core Export features also work with physical replication, including [data integrity checks](https://docs.prequel.co/export/features/data-integrity-checks.md), [orchestration](https://docs.prequel.co/export/features/orchestration.md), and [monitoring](https://docs.prequel.co/export/monitoring/overview.md). The exceptions are listed under [Limitations](#limitations). Data integrity checks are subject to the [supported systems](https://docs.prequel.co/export/features/data-integrity-checks.md#supported-systems) for Apache Iceberg destinations.

> [accordion] Can I mix physically replicated models with other models?
>
> Yes. A destination with physical replication enabled can receive both kinds of models in the same transfer. Models without the setting are transferred with logical replication.
>
> A model with physical replication enabled can only go to destinations that also have it enabled. See [Guardrails](#guardrails). To deliver the same table to other destination types, create a second model on the same `source_table` without the setting.

> [accordion] Can I switch an existing model or destination to physical replication?
>
> No. The setting is fixed when the model or destination is created. Create a new model and a new destination with `otf_acceleration_enabled` set to `true`.

> [accordion] How does Prequel detect changes without querying the table?
>
> Logical replication filters rows by the model's `last_modified_at` column. Physical replication compares files. Each transfer copies only the data files the destination does not already have, then commits a snapshot that matches the source.

> [accordion] Are deletes in the source table replicated?
>
> Yes. Rows deleted from the source table are removed from the destination table on the next transfer. Files that are no longer needed are then removed from the destination bucket after the destination's [retention window](https://docs.prequel.co/export/destinations/iceberg.md#understanding-iceberg-configuration-options).

> [accordion] Do I need to compact the source table?
>
> Yes, before a model's first transfer to a destination and before any full refresh. Iceberg can record deleted rows in separate delete files instead of rewriting the data files. The first transfer and full refreshes fail if the recipient's partitions still have any delete files, so compact those partitions in your query engine first. Delete files in other recipients' partitions are ignored.
>
> Compaction must also remove the delete files themselves. Some engines rewrite the data files but leave the old delete files in the table, and the transfer still fails until they are removed.
>
> Incremental transfers replicate delete files and do not need compaction. Data files are copied unchanged, and position delete files are rewritten so that their file paths point at the destination bucket.

## See also

> [card] [Apache Iceberg source](https://docs.prequel.co/export/sources/iceberg.md)
>
> Connect an Iceberg catalog as a source.

> [card] [Apache Iceberg destination](https://docs.prequel.co/export/destinations/iceberg.md)
>
> Set up an Iceberg destination for a recipient.

> [card] [Multi-tenancy](https://docs.prequel.co/export/concepts/multi-tenancy.md)
>
> Understand how Prequel isolates data per recipient.

> [card] [Change detection](https://docs.prequel.co/export/features/change-detection.md)
>
> See how logical replication detects changed rows.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.