# Should Your Pipeline Sync a Table Into Lakebase, or Write to It Directly?

> One keeps a lakehouse table read-only in Postgres; the other lets a streaming job own its destination table — and the wrong pick breaks at the next refresh.

- Canonical: https://lakenaut.dev/blog/should-your-pipeline-sync-a-table-into-lakebase-or-write-to-it-directl-e4yr/
- Author: Fernando De Nitto
- Published: 2026-11-21
- Kind: decision
- Tags: Databricks, Data Engineering, Lakebase, Postgres, Data Platform
- Concepts: [Synced tables, from Unity Catalog into Postgres](https://lakenaut.dev/concepts/lakebase-synced-tables.md), [Lakebase, the Postgres inside Databricks](https://lakenaut.dev/concepts/lakebase-overview.md), [Computes, autoscaling, scale-to-zero and high availability](https://lakenaut.dev/concepts/lakebase-computes-scaling.md)
- Licence: CC BY-NC-SA 4.0

A team building a customer-facing screen needs a number the lakehouse already computes — a risk score, a recommendation, a lifetime-value figure refreshed nightly in a gold table. A SQL warehouse can answer that query, but not at the latency or the connection count a web page needs, and nobody wants an application holding a warehouse session per request. [Lakebase](https://lakenaut.dev/concepts/lakebase-overview/) exists for exactly this: a managed Postgres database sitting next to the lakehouse, sharing storage and governance with it instead of living on a separate server someone has to patch.

The question that comes next sounds smaller than it is: how does the data actually get there? Lakebase now takes writes two different ways, and they are not interchangeable. One copies a table that already exists in Unity Catalog. The other lets a Structured Streaming job write straight into a table it owns. Pick the wrong one and you find out at the next schema change, the next full refresh, or the next time two writers collide on the same row.

## Two doors, two owners

A [synced table](https://lakenaut.dev/concepts/lakebase-synced-tables/) is a managed copy of a Unity Catalog table — a managed or external Delta table, an Iceberg table, a view or a materialized view — kept current inside Lakebase by a pipeline Databricks runs for you. Creating one gives you two objects: a synced-table entry in Unity Catalog and a real Postgres table your application queries. That table is [read-only from the application's side](https://docs.databricks.com/aws/en/oltp/projects/sync-tables): your identity gets `SELECT`, `DELETE` and `TRUNCATE` on it, never `INSERT` or `UPDATE`, because the sync pipeline owns the data and overwrites anything you change on the next run. You choose a sync mode — Snapshot for a full copy each cycle, Triggered for incremental changes on a schedule or on table updates, Continuous for seconds-of-latency streaming — and the source needs a change data feed for anything but Snapshot.

The [Lakebase streaming sink](https://docs.databricks.com/aws/en/structured-streaming/lakebase) is the opposite shape. A Structured Streaming query writes to it with `.writeStream.toTable("catalog.schema.table")` or, for a table not registered in Unity Catalog, `.format("postgresql")` with an `endpoint` option. If the target table doesn't exist, the sink creates it. You give it an `upsertkey` and it upserts with Postgres's `ON CONFLICT ... DO UPDATE` syntax; on Databricks Runtime 19 and above you can also attach a merge strategy per column — `greatest`, `latestNonNull`, `latestBy(column)` and others — to control how concurrent updates to the same row are resolved. Here the job is the owner. Nothing else writes to that table unless you let it.

That one distinction — who owns the table — is the whole decision.

## The rule

If the data you need already exists as a governed object in the lakehouse — a gold table, a feature table, a materialized view someone else's job maintains — sync it. Building a streaming job whose only purpose is to copy a table that already sits in Delta adds a second moving part for no reason: you now operate a stream instead of a managed sync, and you still don't own the write path, because the real source of truth is still upstream.

If a streaming job is the thing producing the result — a running aggregate, a deduplicated event stream, a score computed row by row as events arrive — and that result's natural home is a transactional table an application reads and writes against, route it through the sink and let the job own the table. A synced table cannot serve this case at all: it can only mirror something that already exists as a Unity Catalog table, and nothing outside the sync pipeline may write to it.

![Synced Table vs. Streaming Sink](https://lakenaut.dev/social/5146288b86a4c9c8f01a1fca09964.png)
Choosing wrong shows up as waste in one direction and as a governance gap in the other. A synced table used to re-serve something that was already streaming adds a landing step in Delta, a second pipeline, and — in Continuous mode — a per-capacity-unit cost for freshness the stream already had. A sink used to rebuild a table that already exists as a governed Unity Catalog asset gives you two write paths into the same data, and the one going through the sink has no lineage back to a catalog object; it is just a Postgres table your job happens to maintain.

## What goes wrong in production

Synced tables fail in ways that are specific to being a managed copy. A duplicate primary key in the source fails the whole pipeline unless you supply a timeseries key to break the tie. Indexes you add in Postgres survive syncs, but a plain `CREATE INDEX` — the only option, since synced tables are partitioned and don't support `CONCURRENTLY` — blocks the sync's own writes until the build finishes; if that takes more than 20 minutes while a sync is waiting, the sync fails and is not retried automatically. And because the table belongs to an internal `databricks_writer` role rather than to you, owner-only features such as row-level security simply cannot be added to it.

The sink fails in ways that are specific to owning the write path. Schema evolution is additive only, and it's checked once, when the query starts — not at every batch boundary — so a column you dropped or renamed upstream doesn't surface as a graceful skip, it surfaces as a failed restart once you add `mergeSchema`. The sink automatically retries transient errors — connection failures, deadlocks, rate limiting — but once it exhausts those retries the query fails outright, and there's no partial-success state to fall back on. `complete` output mode isn't supported, and the sink can't write into a Lakeflow pipeline, so it isn't a drop-in destination for every streaming job you have.

Both sides share one constraint that's easy to miss until it bites: connections. A synced table uses up to 16 connections to Lakebase per table, and a single source can have up to 20 synced tables, so a handful of them already competes for a meaningful slice of whatever a compute allows. The sink opens one connection per task by default, tuned with `spark.databricks.sql.streaming.jdbc.tasksPerConnection`, and pushing too many tasks onto one connection causes contention instead of throughput. Either way, the ceiling is set by the compute size on the Postgres side: a fixed [0.5 CU compute allows 105 connections, 8 CU allows 1,795, 16 CU allows 3,597, and the limit plateaus at 3,993 from 24 CU up](https://docs.databricks.com/aws/en/oltp/projects/manage-computes); for an autoscaling compute, the real ceiling is whichever is smaller — the configured maximum, or eight times the configured minimum. A compute scaled 1–16 CU is still capped at the 8 CU figure.

![Common Mistakes](https://lakenaut.dev/social/5146288b86a4c9c8f11a1fca09964.png)
## Operating each one

A synced table is monitored the way a managed pipeline is monitored: its Catalog entry shows sync state, pipeline status and the last sync timestamp, and because the underlying sync runs as a Database Table Sync pipeline task, its run history and failures surface in Lakeflow Jobs the same as any other scheduled task. Treat a sync that's stuck in `INITIALIZING` for a long time as expected during a large load, and treat a sync that fails after an index build as a sign to move large index builds to a maintenance window rather than a sign to retry blindly.

```sql
-- Confirm a source table still has a usable change data feed
-- before relying on Triggered or Continuous mode
SHOW TBLPROPERTIES main.gold.customer_ltv ('delta.enableChangeDataFeed');
```

The sink is monitored as a streaming query: watch batch duration and input versus processing rate in the job or notebook's streaming UI, and treat a growing backlog or repeated retries as the early warning that the destination can't absorb the write rate — the moment to raise `batchsize`, shorten `batchinterval` for latency-sensitive paths, or revisit how many tasks share a connection, not the moment to wait for the query to fail.

```python
(
    events_df.writeStream
    .outputMode("update")
    .option("upsertkey", "event_id")
    .option("checkpointLocation", "/Volumes/main/gold/checkpoints/events_sink")
    .toTable("main.gold.live_events")
)
```

Before scaling either path, check the destination compute's size against its connection ceiling, not against how many connections you think you'll need. It's the one number that silently caps both a growing list of synced tables and a streaming job with too many tasks per executor.

## Monday

Write down, for every dataset headed into Lakebase, who computes it today — a batch or declarative pipeline job, or a streaming query. That answer decides the mechanism; whichever one shipped more recently should not.

Audit existing synced tables for Triggered syncs running on intervals under five minutes. Below that, you're paying for scheduling overhead a Continuous sync would remove.

If a streaming job already writes to Postgres through a hand-rolled `foreachBatch` function, check whether the built-in sink removes code you don't want to keep — but only once you've confirmed you're on Databricks Runtime 18 LTS or above, and that any merge-strategy logic you need is actually available on your runtime before you commit to it.

## Sources

- https://docs.databricks.com/aws/en/structured-streaming/lakebase
- https://docs.databricks.com/aws/en/oltp/projects/sync-tables
- https://docs.databricks.com/aws/en/oltp/projects/
- https://docs.databricks.com/aws/en/oltp/projects/manage-computes
