Scrivio Interview library
LeadershipPrincipal7 min read · updated 12 November 2026

Your largest databases have grown to tens of terabytes, and every schema change is now a planned event with risk of outage. What long-term strategy would you set for schema evolution, data ownership and database size to keep change safe?

Schema change becomes routine again only if databases and tables stay small enough for online operations to be boring. The long-term strategy is to split data ownership so each service owns a smaller database with fewer consumers, keep hot tables small with partitioning, archival and retention policies, invest in migration linting, online schema change tools and rehearsal on production-sized copies, put contracts such as views or APIs between data and its consumers, and measure change lead time and DDL incidents so the platform work is funded as reliability work.

Why this question is asked

When a database reaches tens of terabytes, the problem is no longer one bad migration. Every change takes hours, needs a maintenance window and a rollback plan, and teams start avoiding schema changes altogether, which slows the business and leads to workarounds like storing new data in JSON blobs. Interviewers ask this of very senior engineers because no single technique fixes it; it needs a strategy that touches architecture, data lifecycle, tooling and how the work is funded. In this answer, we will see why size makes change risky, and then go through ownership, lifecycle, tooling, contracts and measurement, with the reasoning a senior engineer uses to order them.

1Why Size and Sharing Make Change Risky

Two forces turn a schema change into an event. The first is size. Any operation that scans, rewrites or copies a table takes time proportional to its size. A concurrent index build on a 200 GB table might take half an hour; on a 12 TB table it can take more than a day, and during that time it competes with production traffic for disk and memory, holds back vacuum, and produces a large volume of WAL that replicas must replay. Backfills, validations and online schema change tools all have the same scaling.

The second force is sharing. When a database is used by many applications, reports and ad hoc scripts, nobody knows every reader of a column, so even an additive change needs coordination and a destructive one feels impossible. Large shared databases usually have both problems at once, because sharing is how they got large.

2Split Ownership: Smaller Databases With Fewer Consumers

The first lever is ownership. Each service owns its data, and other services and teams reach it through that service's API or published events, never by reading its tables. A schema change then affects one team's code, which that team can change in the same week. Splitting also divides size: instead of one 40 TB database, we end up with several databases of a few terabytes each, where online operations are routine again.

This is slow, deliberate work, done one business capability at a time: identify the tables a domain owns, route all other access through an API or a read model, then move the tables to their own database. We start with the domains that change most often or cause the most DDL pain, because that is where the payoff is largest.

3Keep Hot Tables Small: Partitioning, Archival and Lifecycle

Most of the bytes in a large operational database are old data that is rarely read: orders from five years ago, closed tickets, event logs. Yet every schema change must process them. A data lifecycle policy decides, per table, how long data stays in the hot database, when it moves to cheaper storage, and when it is deleted, with legal and business owners agreeing on the periods.

Partitioning makes the policy cheap to apply. A table partitioned by month is really many smaller tables. Old partitions can be detached and archived in a quick metadata operation instead of a slow DELETE, and indexes can be built per partition, so each build is small.

SQL
CREATE TABLE orders (id bigint, created_at timestamptz NOT NULL, ...) PARTITION BY RANGE (created_at);
CREATE TABLE orders_2026_10 PARTITION OF orders
FOR VALUES FROM ('2026-10-01') TO ('2026-11-01');
-- Archival: detach an old month without blocking queries on the rest (PostgreSQL 14 and later)
ALTER TABLE orders DETACH PARTITION orders_2021_10 CONCURRENTLY;
-- then export orders_2021_10 to the archive and drop it

With a 13-month retention in the hot table, an orders table that would be 30 TB after ten years stays at roughly 3 TB, and every future migration is ten times cheaper. That is the kind of number that persuades leadership to fund the work.

4Invest in Tooling and Rehearsal

Safe change at scale depends on tools that people trust. Migration linting in every pull request rejects operations known to block. Online schema change tools such as gh-ost or pt-online-schema-change for MySQL, and patterns such as concurrent index builds, NOT VALID constraints and batched backfills for PostgreSQL, are packaged by the platform team so teams use them without being experts.

Rehearsal is the step large organisations most often skip. We keep a production-sized copy, refreshed regularly with personal data masked, and run every large migration there first, measuring how long it takes, how much WAL it produces and how far replicas fall behind. A migration that takes nine hours in rehearsal is planned very differently from one that takes nine minutes, and we learn this before production rather than during it.

5Contracts Instead of Direct Table Access

For consumers we cannot remove quickly, such as reporting tools or a partner integration, we put a contract between them and the tables. A versioned view like reporting.orders_v1 or an API endpoint lets us change the tables behind it while the contract stays fixed. Changes to the contract itself are additive by default: new columns or fields are added, and removals happen only in a new version with a deprecation period.

The same rule applies to our own changes. We prefer additive, backward-compatible schema changes, using expand and contract for anything that would break readers, so most changes never need coordination at all.

Step throughWhere each lever acts
  1. ConsumersAPIs, events, versioned views as contracts
  2. Ownershipone service owns each database
  3. Lifecyclepartitions, retention, archival
  4. Toolinglinting, online DDL, rehearsal on copies
  5. Measurementlead time, DDL incidents, funding

5 layers, from the top down. Step through them one at a time.

Each layer reduces either how many people a change affects or how much data it has to touch.

6Measure It and Fund It as Reliability Work

Platform work like this competes with features for funding, and it loses unless its value is visible. We measure two things. Change lead time for schema changes: how long from a merged migration to it being live in production, which on a struggling platform might be three weeks including a maintenance window. And DDL incidents: outages or degradations caused by schema changes or their locks, with their customer impact. We also track database size and growth per domain.

Presented together, these numbers make the case in terms leadership already uses: every maintenance window costs a measurable amount of revenue or engineering time, and every incident has a cost. We set targets, for example schema change lead time under one day and zero unplanned DDL incidents per quarter, fund the work as a reliability investment with a roadmap of domains to split and tables to partition, and report progress every quarter. The order of work follows the data: the tables that cause the most pain and grow fastest come first.

7Follow-up questions

Is sharding the answer to tens of terabytes?

Sometimes, but it is the most expensive option and it does not fix sharing. Sharding spreads one schema over many nodes, so a migration must still run everywhere, now with coordination. Splitting by ownership and keeping hot data small usually removes most of the pain first; sharding is for a single domain that is genuinely too large or too busy for one node after that.

How do you get legal and business agreement on retention?

We present each large table with its size, growth, read patterns and the cost of keeping it hot, and propose a retention period with archival rather than deletion where data must be kept. Legal and the business owner decide the period; engineering makes archived data retrievable on request, which usually removes the fear of moving it.

What is the first thing you would do in the first month?

Measure: list the largest tables, who reads them, how often they change, and the last year of DDL incidents and maintenance windows. That gives a ranked list of where size and sharing hurt most, and it produces the baseline numbers the funding case needs.

8Conclusion

In this answer, we saw that schema change becomes risky when databases are both huge and shared. The long-term strategy attacks both: split ownership so each service owns a smaller database with fewer consumers, keep hot tables small with partitioning and lifecycle policies, provide linting, online schema change tools and rehearsal on production-sized copies, protect remaining consumers with contracts such as views and APIs and prefer additive change, and measure lead time and DDL incidents so the work is funded and tracked as a reliability investment.

What to say in the interviewAbout 90 seconds aloud

Open with

I would treat this as two problems, size and sharing, because together they turn every schema change into an event. For sharing, I would move toward each service owning its data, with other teams using APIs or events instead of reading tables.

Then, if they want more

That shrinks the set of people affected by a change and also divides the database into smaller ones. For size, I would set data lifecycle policies with the business and legal teams, partition the largest tables by time, and archive old partitions with DETACH PARTITION instead of deleting rows.

Keeping, say, thirteen months hot can make a table ten times smaller, and every future migration ten times cheaper. Then tooling: migration linting in every pull request, packaged online schema change tools, and rehearsal of big migrations on a masked production-sized copy so we know the duration and replica lag before we start.

For consumers we cannot move yet, I would put versioned views or APIs in front of the tables and keep changes additive with expand and contract.

Finally, I would measure schema change lead time and DDL incidents, set targets, and present the cost of maintenance windows and outages to leadership, so this is funded as reliability work with a quarterly roadmap that starts with the tables causing the most pain.

About this answer

Last updated
12 November 2026
Versions it names
PostgreSQL 14
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Your largest databases have grown to tens of terabytes, and every schema change is now a...": https://scrivio-interview-library.netlify.app/databases/database-locking/304b148951/