Scrivio Interview library
ConceptFoundations6 min read · updated 12 November 2026

A product manager asks for reports directly from the production database. Compare using a read replica with building a warehouse.

A read replica is a live copy of the production database: easy to set up and nearly real time, but reports must work against normalised operational tables, long queries are limited by the replica's capacity and can be cancelled by replication conflicts or delay replication. A warehouse models data for analysis as facts and dimensions, keeps history, combines several sources and scales for heavy queries, at the price of latency from minutes to hours and a pipeline to maintain. Start with a replica for a few simple reports and move to a warehouse once reports span services or need history.

Why this question is asked

Reports straight from the production database are a classic request, and saying yes without thinking can slow down the product for customers, while saying no without an alternative frustrates the business. A senior developer should offer the right next step. Interviewers ask this to see whether we know why reporting load does not belong on the primary and what each alternative really costs. In this answer, we will see why the primary is off-limits, look at how a read replica works and where it hits limits, explain what a warehouse adds, compare the two, and finish with a practical path from one to the other.

1Why Not the Production Primary

The primary database serves the application: every order, login and payment goes through it. A report that scans a year of orders reads gigabytes, fills the shared cache with data customers do not need, and uses CPU and I/O that live traffic is waiting for. A badly written report with a missing join condition can run for an hour. In PostgreSQL, a long-running query also holds back vacuum from cleaning old row versions, so tables bloat while it runs.

So the real question is not whether to report from production, but from which copy of production data.

2How a Read Replica Works

A read replica, or hot standby in PostgreSQL terms, is a second server that continuously receives the primary's write-ahead log and replays it, so it holds the same data, usually less than a second behind. It accepts read-only queries. Setting one up is mostly configuration, and most managed database services create one with a click.

For a product manager's first reports this is attractive. The data is fresh, the tables are the ones developers already know, the reporting tool can connect with an ordinary SQL connection, and nothing new needs to be built.

SQL
-- on the replica
SELECT pg_is_in_recovery(); -- true: a standby
SELECT now() - pg_last_xact_replay_timestamp() AS replay_lag; -- 00:00:00.4
-- a typical first report: orders per day last week
SELECT created_at::date AS day, COUNT(*), SUM(total)
FROM orders
WHERE created_at >= current_date - 7
GROUP BY 1 ORDER BY 1;

3Where a Replica Hits Its Limits

The first limit is the schema. Operational tables are normalised for the application: an order's customer, address, items, discounts and payment status live in separate tables, statuses are codes, and history is overwritten. A report that sounds simple, revenue by customer segment and month net of refunds, becomes a ten-table query that each analyst writes slightly differently.

The second limit is capacity. A replica has the same hardware shape as the primary and is tuned for short queries. Heavy reports compete with each other, and if the replica also serves application reads, they slow the application down.

The third limit is replication itself. On a PostgreSQL hot standby, the primary may remove old row versions that a long report on the replica still needs to see. The replica then either delays replaying WAL, so it falls behind, or cancels the query with the error canceling statement due to conflict with recovery. Settings can shift that balance, but long reports and up-to-date replicas pull against each other.

Finally, a replica only contains one database. Once a report needs data from the billing service and the CRM as well, a replica cannot help.

4What a Warehouse Adds

A warehouse is a separate database designed for analysis. Data arrives from each source through a pipeline, by CDC or batch loads, and is modelled into fact tables of business events and dimension tables of context, such as fact_orders with dim_customer and dim_date. Statuses become readable labels, refunds and payments are joined in once, and every analyst uses the same clean model.

It also keeps history the operational database discards, such as which plan a customer had last March, combines data from many services and external tools, and runs on column-oriented engines that scan billions of rows quickly without touching production. The costs are latency, since data typically arrives minutes to hours after it happened, and a pipeline and models that someone must build, test and maintain.

Read replica compared with a warehouse
ConcernRead replicaWarehouse
Setupconfiguration, hourspipeline and models, weeks
Freshnessseconds behindminutes to hours behind
Schemaoperational, normalisedfacts and dimensions for analysis
Historyonly current statekept, including changed attributes
Sourcesone databasemany services and tools
Heavy querieslimited, can conflict with replaybuilt for large scans

5A Practical Path

For the product manager's request, I would propose a staged answer. Start with a dedicated reporting replica, separate from any replica the application uses, and a handful of saved queries or views that encode the business logic once, such as a view of orders with readable statuses. Set a statement timeout for the reporting role so a runaway query cannot run for hours.

SQL
CREATE ROLE reporting LOGIN;
ALTER ROLE reporting SET statement_timeout = '5min';
GRANT SELECT ON orders_report_v TO reporting; -- views, not raw tables
Step throughChoosing where reports run
  1. Do reports need several services?
    YesWarehouseNoNext question
  2. Do they need history over time?
    YesWarehouseNoNext question
  3. Are they few and simple?
    YesDedicated reporting replicaNoWarehouse
  4. Recheck as reports growconflicts, metric drift, new sources

4 steps in order. Play them, or step through them one at a time.

Then watch for the signals that the replica is no longer enough: reports that need data from a second service, questions about how something looked in the past, queries cancelled by recovery conflicts, or more than a few people writing their own versions of the same metric. When those appear, it is time to build a warehouse, starting with the reports that hurt most, and to move reporting off the replica one subject area at a time.

6Follow-up questions

Can the application's own read replica serve reports too?

It can, but it is risky: a heavy report slows the application's reads on that replica, and settings that help reports, such as longer replay delays, make the application read staler data. A separate reporting replica keeps the two workloads apart.

Is a logical replica better than a physical one for reporting?

A logical replica, using PostgreSQL's publications and subscriptions, can hold only selected tables, have its own indexes and even extra tables for reporting, and does not suffer the same recovery conflicts. It needs more care with schema changes, which must be applied on both sides.

How fresh does a warehouse need to be?

It depends on the use. Daily management reports are fine with a nightly load; operational dashboards may need data within 15 minutes, which CDC-based pipelines can deliver. Real-time needs of seconds usually belong to a different system.

7Conclusion

In this answer, we compared a read replica with a warehouse for reporting. A replica is a near real time copy that is easy to set up, but reports must use normalised operational tables, are limited by the replica's capacity and can be cancelled by replication conflicts. A warehouse models data as facts and dimensions, keeps history, joins many sources and scales for heavy queries, in exchange for latency and a pipeline to maintain. The practical path is a dedicated reporting replica first, and a warehouse once reports cross services or need history.

What to say in the interviewAbout 80 seconds aloud

Open with

I'd first steer reports away from the primary, because heavy queries compete with customers for CPU, I/O and cache, and in PostgreSQL long queries also hold back vacuum.

Then, if they want more

Then it's a choice between a read replica and a warehouse. A replica is a hot standby replaying the primary's WAL, usually under a second behind. It takes hours to set up and the data is fresh, so it's great for a few simple reports.

But reports have to work with the normalised operational schema, so every analyst writes their own ten-table joins. Capacity is limited, and long queries conflict with replication: the standby either lags or cancels them with a conflict with recovery error. And it only holds one database.

A warehouse is built for analysis: data from all services lands through a pipeline and is modelled as facts and dimensions, it keeps history, and it scales for big scans without touching production. The cost is latency, minutes to hours, and a pipeline and models to maintain.

So I'd propose a dedicated reporting replica now, with views that encode the business logic and a statement timeout on the reporting role, and move to a warehouse once reports span services, need history, or keep getting cancelled.

About this answer

Last updated
12 November 2026
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 "A product manager asks for reports directly from the production database. Compare using...": https://scrivio-interview-library.netlify.app/databases/analytics-and-cdc/9a2c6485b9/