---
title: "Breaking up a monolith: How we’re unwinding a shared database at scale"
description: "Datadog is splitting its large shared Postgres database into independently owned instances through a three-phase plan: logical separation into per-domain private schemas with explicit ACLs, access reduction so only owning teams query their tables directly, and physical separation onto managed OrgStore instances."
url: "https://swe.quest/articles/breaking-up-a-monolith-how-we-re-unwinding-a-shared-database-at-scale-4f34dacf50e040a9"
canonical: "https://www.datadoghq.com/blog/engineering/unwinding-shared-database/"
source: "Datadog Engineering"
published: "2025-06-17"
difficulty: "medium"
kind: "Case study"
reading_minutes: 20
tags: ["postgres","schema-migrations","refactoring","microservices","replication"]
---

# Breaking up a monolith: How we’re unwinding a shared database at scale

A post on [Datadog Engineering](https://swe.quest/sources/datadog.md), published 2025-06-17, 20 min read, Case study. Original: [https://www.datadoghq.com/blog/engineering/unwinding-shared-database/](https://www.datadoghq.com/blog/engineering/unwinding-shared-database/)

## Summary

Datadog is splitting its large shared Postgres database into independently owned instances through a three-phase plan: logical separation into per-domain private schemas with explicit ACLs, access reduction so only owning teams query their tables directly, and physical separation onto managed OrgStore instances. Domain boundaries came from clustering Database Monitoring query samples and validating them with 30+ teams. Inter-domain foreign keys were replaced with CDC or Postgres replication. A homegrown PG Proxy lets teams migrate at their own pace and makes cutover a dynamic config change, with write downtime under five seconds and reverse replication kept for rollback. The platform investments that made this feasible, the Rapid service framework, OrgStore and PG Proxy, are presented as prerequisites, and each phase has concrete progress metrics.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Schema migrations](https://swe.quest/tags/schema-migrations.md) (Data & databases)
- [Refactoring & migrations](https://swe.quest/tags/refactoring.md) (Engineering practices)
- [Microservices](https://swe.quest/tags/microservices.md) (Backend & APIs)
- [Replication](https://swe.quest/tags/replication.md) (Distributed systems)

## Prerequisites

- PostgreSQL schemas and roles ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- database replication ([easy posts on Databases](https://swe.quest/tags/databases.md?difficulty=easy))
- connection pooling

## Keywords

Datadog, PostgreSQL, OrgStore, PG Proxy, Rapid, PgBouncer, Change Data Capture

## Related posts

- [The growing pains of database architecture](https://swe.quest/articles/the-growing-pains-of-database-architecture-9202c659b7981acc.md): Figma · 2023-04-04 · Medium · 12 min read · PostgreSQL, Schema migrations, Scaling, Replication, Databases
  Facing ~3x annual database traffic growth and 65% peak CPU on a single Amazon RDS Postgres instance, Figma chose vertical partitioning (moving groups of tables to their own databases) over horizontal sharding, NewSQL, or self-hosting.
- [How we migrate TBs from Heroku without logical replication](https://swe.quest/articles/how-we-migrate-tbs-from-heroku-without-logical-replication-e0568c616a878849.md): PlanetScale · 2026-11-11 · Medium · 12 min read · PostgreSQL, Schema migrations, Replication, Networking
  PlanetScale's open-source Heroku Migrator moves multi-terabyte Postgres databases off Heroku standard plans, which lack WAL access and logical replication, by using Bucardo trigger-based replication: triggers record changes in delta tables, a one-time COPY loads existing data, and a worker replays the backlog before a controlled switchover with verification.
- [How to Keep Staging in Sync with Production in Postgres](https://swe.quest/articles/how-to-keep-staging-in-sync-with-production-in-postgres-2a3ed8d4d274df22.md): Neon · 2025-12-23 · Medium · 5 min read · PostgreSQL, Replication, Privacy, Testing
  Postgres staging environments drift from production, and the traditional fixes each fall short. pg\_dump/pg\_restore gives a clean copy but takes staging offline and runs for hours on large databases.
- [Promoting Postgres Changes Safely From Multiple Environments to Production](https://swe.quest/articles/promoting-postgres-changes-safely-from-multiple-environments-to-production-f145de15aea44a98.md): Neon · 2025-11-25 · Medium · 9 min read · PostgreSQL, Schema migrations, Deployment, Multi-tenancy
  A snapshot-based workflow for promoting Postgres schema and data changes uses two isolated root branches, prod and dev, linked only through Neon snapshots.
- [Why Your Staging Database Never Matches Production](https://swe.quest/articles/why-your-staging-database-never-matches-production-0082e7428bf22c68.md): Neon · 2025-12-12 · Medium · 8 min read · PostgreSQL, Testing, Schema migrations, Privacy
  Staging databases drift from production continuously in three ways: data drift (stale dumps, sequence values that diverge so the same ID points to different records), schema drift (hotfixes, skipped migrations, mismatched indexes and extensions causing query plan divergence), and transformation drift (anonymization that breaks uniqueness, referential integrity and determinism).

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
