GLOSSARY

What is database branching?

Database branching creates isolated, writable copies of a database using copy-on-write technology. Like git branches for code, database branches let developers and AI agents modify data and schemas without affecting the parent database. Branches create in seconds regardless of database size and only store the changes you make.

HOW IT WORKS

How database branching works

Database branching works by leveraging copy-on-write (CoW) at the storage layer. When you create a branch, the system doesn't duplicate any data. Instead, it creates a new reference that points to the same storage pages as the parent database.

When you write to the branch — inserting rows, modifying data, altering schemas — only the modified pages are copied. The rest continue to be shared with the parent. This is why a 1 TB database can branch in under 6 seconds and initially costs 0 MB of additional storage.

Each branch has its own compute (Postgres process), so queries on the branch don't affect the parent's performance. Branches are fully writable: you can run DDL (CREATE, ALTER, DROP), DML (INSERT, UPDATE, DELETE), and any SQL you'd run on the original database.

When the branch is no longer needed, deleting it reclaims only the storage used by modified pages. The parent database is never affected by branch operations — creating, modifying, or deleting a branch has zero impact on production.

WHY IT MATTERS

Why database branching matters

Database branching solves one of the hardest problems in software development: testing against real data safely. Before branching, teams had three options for testing database changes:

1. Test against production — fast but dangerous. A bad migration can cause outages and data loss.

2. Maintain staging environments — safe but expensive and always out of sync. Migrations that pass staging but fail in production are a leading cause of database outages.

3. Use empty test databases — cheap but useless for catching real bugs. Edge cases only surface with real data.

Branching gives you a fourth option: test against a production-identical copy that creates in seconds, costs almost nothing, and is fully isolated. This is especially valuable for AI coding agents that need to interact with real database schemas and data to generate correct SQL.

EXAMPLE

database branching in practice

-- Using Ardent CLI to branch a production database

$ ardent branch create feature-user-prefs
✓ Branch created in 5.8s
postgres://branch-feat01.db.tryardent.com:5432/mydb

-- Connect to the branch and work freely
$ psql postgres://branch-feat01.db.tryardent.com:5432/mydb

ALTER TABLE users ADD COLUMN preferences jsonb DEFAULT '{}';

UPDATE users SET preferences = '{"theme": "dark"}'
WHERE created_at > '2025-01-01';
-- 127,843 rows updated (only on the branch)

-- Review changes
$ ardent branch diff
-- Shows every row-level change across all modified tables

-- Delete when done
$ ardent branch delete feature-user-prefs

The example above shows a typical branching workflow: create a branch, run a migration against real data, validate constraints, review the diff, and clean up. The entire process takes minutes instead of hours.

RELATED CONCEPTS

Related terms

Copy-on-Write
Database Sandbox
Change Data Capture
Ephemeral Environments
FAQ

Frequently asked questions

What is database branching?

Database branching creates isolated, writable copies of a database using copy-on-write technology. Branches create in seconds and only store changes, not full copies.

How is branching different from cloning?

Cloning creates a full physical copy (duplicating all storage). Branching uses copy-on-write to share storage, creating in seconds vs. hours at a fraction of the storage cost.

What databases support branching?

Neon provides branching for Neon-hosted Postgres. Ardent provides branching for any Postgres database (Supabase, RDS, self-hosted). Most traditional databases don't support branching natively.

Try database branching with Ardent

Create isolated database branches in under 6 seconds. No risk to production.

Read the docsBook a demo