PostgreSQL · Lakebase Postgres · Databricks

Restoring 5 TB of Postgres in 5 seconds

A Lakebase Postgres branch is an isolated instance of your postgres database. I grew one database from 22 GB to 5 TB and timed branch creation at every step.

If you’re a database operator, you know that your data is only as good as your backups. How quickly can you restore? How quickly can you do a point-in-time recovery? With agents developing against the database, we also find ourselves asking “How quickly can we recover from an error?”, and then “How quickly can you copy that database to a sandbox?”.

Lakebase Postgres, available on Databricks and Neon, has the best possible answer to this question: “5 seconds”.

Lakebase Postgres calls this branching (like git). A branch of your database is a near-instant, lightweight clone of the entire Postgres instance. It even has its own host, and it’s completely isolated from the parent branch.

What a branch is

A branch is a lightweight clone: a new, independent Postgres database that sees exactly what its parent had at a point in time. That doesn’t mean the data gets copied: when the branch is created, nothing is copied at all. The branch shares the parent’s storage and reads the same pages the parent had at that moment, and it only stores pages of its own once it changes them. It includes:

  • every database, schema, table, index and sequence
  • all the data
  • roles and grants
  • installed extensions
  • database- and role-level settings (ALTER DATABASE ... SET, ALTER ROLE ... SET)

Since Lakebase Postgres separates compute from storage, we have the full history of every page as WAL, so a branch is a new timeline that starts at an LSN (a WAL position) in the parent’s history. The branch’s compute reads the same pages the parent had at that moment. Postgres keeps the catalog in the same pages as the data, so if the pages are identical, so is the schema.

After that, the branch is copy-on-write: reads of unchanged pages come from the shared history, and only pages the branch modifies are stored separately. Each branch runs on its own compute, so the parent’s compute keeps serving its application while the branch is created and used. The parent never sees the branch’s changes, and the branch never sees the parent’s.

What a branch doesn’t inherit is anything that lives in the parent’s running server rather than in storage: open connections and sessions. The branch starts its own compute. Each compute gets a unique hostname that you can connect to, and you are completely isolated from the others.

How I tested

I created a single Lakebase Postgres project on Databricks and increased the data size in 6 increments from 22GB to 5 TB.

  • Data: synthetic, one wide table shape (a bigint id plus 100 double precision columns, about 935 bytes per row), loaded in ~200 GB shards.
  • Compute: Postgres 17, autoscaling 1–8 CU.
  • Client: one host, about 60 ms round trip from the database region.
  • Repetitions: 12 branch creates at each size.
  • Branch create time: from just before the create-branch API call until the operation it returns reports done.

Results

Branch create time, 12 runs at each size.

Parent size p50 (s) p95 (s) mean (s) stddev (s)
22.1 GB 3.05 3.27 3.08 0.13
100.1 GB 3.08 5.71 3.51 1.59
504.1 GB 5.01 5.96 4.88 0.88
1.01 TB 5.67 5.92 5.16 0.82
2.02 TB 4.53 5.84 4.86 0.87
5.02 TB 4.47 6.03 4.70 0.80

A Friday afternoon

It’s 2 PM on Friday and production canaries start alarming that user logins are failing. You look and find that the accounts table has been dropped from production by a rogue agent. How do you recover?

If you’re on Lakebase Postgres, you issue one command to create a branch at 1:59 PM. Within about 5 seconds you have a full snapshot of your database restored and ready to use. At this point, you can point production to it, or bring the data over on your own.

Lucky you were on Lakebase Postgres: restoring 4 TB at other providers would take hours.

Branches from a point in the past

You can branch from a timestamp or an LSN in the history window, not just from now. I tested that at 1, 2 and 5 TB, from about 1 hour back up to the oldest point available (5–10 hours).

  • Create time from a past timestamp or LSN: 4.26 s (timestamp) and 4.42 s (LSN) p50 at 5.02 TB, the same range as creating from now.
  • Correctness: before each point I wrote a numbered marker row. Every branch showed exactly the markers that existed at its point, and none written after. At 2 TB, a branch at 21:18:30.000 saw marker 5 and not marker 6, which was written at 21:18:30.545.
  • Reads: the mean page fetch time during lookups was 1.34–1.51 ms at every age and size.
  • Cold reads at old points: on the 5 TB parent, the first branch at an old (5–10 h) point had a handful of 1–10 s page fetches in its first lookups. Later branches at the same point didn’t. Older history is probably being fetched from object storage the first time it’s needed.

What it costs the parent, and storage

  • Parent workload: I ran a write workload on the parent and created and deleted a branch every 20 seconds for 5 minutes, with 2 minutes of the same workload before and after. A light workload (about 130 small transactions/s) and a heavy one (about 43,000 inserted rows/s) both ran at the same throughput and p99 before, during and after branching, at every size.
  • Storage: right after create and first connect, a branch owns about 166 KB of WAL at every size. Updating rows on the branch writes WAL in proportion to the change:
Parent size Rows updated on the branch (1%) WAL written As % of parent
504.1 GB 5,346,000 5.59 GB 1.11%
1.01 TB 10,691,000 11.18 GB 1.11%
2.02 TB 21,381,000 22.37 GB 1.11%
5.02 TB 53,451,000 55.92 GB 1.11%

The update was contiguous (the first 1% of ids in each table). Scattered updates touch more pages per row changed.

Try it yourself

On Databricks

Lakebase Postgres is included in Databricks Free Edition (one Lakebase Postgres project per account, with scale-to-zero compute). Sign up, then install the Databricks CLI and log in to your workspace:

databricks auth login --host https://<your-workspace>.cloud.databricks.com

Create a project. It comes with a default branch, production, and a compute for it:

databricks postgres create-project my-app
databricks postgres list-endpoints projects/my-app/branches/production

Create a branch of it, from now:

databricks postgres create-branch projects/my-app dev --ttl 24h

Or from a point in the past, for the Friday-afternoon case:

databricks postgres create-branch projects/my-app before-the-drop --json '{
  "spec": {
    "source_branch": "projects/my-app/branches/production",
    "source_branch_time": "2026-11-20T18:59:00Z",
    "ttl": "86400s"
  }
}'

Each branch gets its own compute with its own hostname. Find it, get a credential, and connect with psql:

databricks postgres list-endpoints projects/my-app/branches/before-the-drop
export PGPASSWORD=$(databricks postgres generate-database-credential \
  projects/my-app/branches/before-the-drop/endpoints/primary -o json | jq -r .token)
psql "host=<host from list-endpoints> dbname=databricks_postgres user=<your login email> sslmode=require"

On Neon

Lakebase Postgres branching works the same way on Neon. The Free plan needs no credit card; it keeps up to 6 hours (or 1 GB of changes) of history for point-in-time branches. Install the CLI and log in:

npm install -g neonctl
neonctl auth

Create a project and note its ID:

neonctl projects create --name my-app

Create a branch from now, and one from a point in the past (a timestamp as the parent branches from the default branch at that moment):

neonctl branches create --project-id <project-id> --name dev --parent main
neonctl branches create --project-id <project-id> --name before-the-drop --parent "2026-11-20T18:59:00Z"

Each branch has its own compute and connection string:

psql "$(neonctl connection-string before-the-drop --project-id <project-id>)"