# Read Replica vs Data Warehouse: When to Stop Running Analytics on Production

> Reports slowing production? Compare read replicas and data warehouses on load, freshness, cost and joins, plus 7 signs it's time to switch.

Source: https://www.erathos.com/en/blog/read-replica-vs-data-warehouse
Em português: https://www.erathos.com/blog/read-replica-vs-data-warehouse
Published: 2026-11-23
Category: Data Engineering

![Read Replica vs Data Warehouse](https://cms-media.erathos.com/Read Replica vs Data Warehouse.png)

The initial dashboard built at most companies growing rapidly usually connects to the production database directly. But as soon as someone generates a report covering the previous twelve months of data, the app will start slowing down significantly for other users. To fix this, teams often set up a read replica. However, after some time, the read replica will start killing queries, lagging behind, and becoming as expensive as the primary database.

Each of these steps made sense at the time and addressed a particular problem, but created other issues. How do you know if you should make the next step? This blog post will list a few key signs in your database that you can look out for.

There are three main stages to this:

**\[IMAGE 1: upload gtm-1478-img1.png here\]**

## Stage 1: reports on the production database

Teams often start out running reports on the production database, since there's zero setup cost. You already have the database. You have the BI tool. You've got the connection string. All the data is up-to-date.

But running the report on the production database means your customers are sharing the same database as your reports. If your report needs to scan through a year of orders, it will compete with checkout and login for CPU, memory, and disk.

In PostgreSQL, there's another subtle issue: when you update or delete a row, PostgreSQL keeps the old version around [as long as any open transaction might need to see it](https://www.postgresql.org/docs/current/routine-vacuuming.html). It's the job of the background VACUUM process to clean up these dead row versions, but it can't do so until the transaction ends. Running a long report keeps a transaction open, which can cause tables to grow by preventing VACUUM from doing its job, and VACUUM itself also causes heavy disk traffic that impacts other sessions.

Then there are locks. A simple SELECT statement takes a weak lock, [which conflicts only with the strongest lock](https://www.postgresql.org/docs/current/explicit-locking.html), such as the lock taken by many forms of ALTER TABLE. If a migration is run while a long-running report is still open, the migration will have to wait for the report to complete. PostgreSQL will wait indefinitely for a lock to be released, unless there's a deadlock or a lock timeout, so a long-running report can block a deploy.

## Stage 2: a read replica

A read replica is a read-only copy of the production database. The read replica is [asynchronously updated with any changes on the primary database](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_ReadRepl.html) as Amazon RDS takes care of the replication. The BI tool is updated to point to the read replica database. AWS highlights business reporting as one of the main reasons to set up a read replica. Since customer traffic and reports now run on different machines, the big reports won't slow down the checkout process.

This fixes the shared machine problem. But the following issues remain:

- **It is the same engine.** The data is still stored in rows, and joining many large tables with months of data is as slow as before. Standbys are read-only, so you cannot add indexes only on the replica.
- **It lags behind.** The data on the replica is [eventually consistent](https://www.postgresql.org/docs/current/hot-standby.html) with the primary, so there is always some lag. On RDS for PostgreSQL, even when there is no data missing, the replica can [report up to five minutes lag](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_PostgreSQL.Replication.ReadReplicas.html) when the primary is not busy, because RDS switches the WAL file every five minutes by default.
- **Long queries get cancelled.** When VACUUM cleans up rows on the primary, the replica has to apply the change, but if the report on the replica still needs these rows, PostgreSQL waits for a period of time and then cancels the report. This happens a lot on tables that change frequently.
- **The workarounds push the problem back.** You can increase the wait time to allow the report to finish, but then other sessions on the replica will see stale data. Or you can enable `hot_standby_feedback` to prevent the cancellations, but then the primary will keep dead rows, which returns you to the table bloat issue on the primary.
- **It is a second full database bill.** RDS charges for a replica as a normal database instance with the price of its instance class, and there is no automatic scaling for replicas.

Here is how the cancellations and the feedback fix connect:

**\[IMAGE 2: upload gtm-1478-img2.png here\]**

The PostgreSQL docs say that with the feedback setting enabled, the cleanup situation "will be no worse than if the standby queries were running directly on the primary server." So the main workaround for cancellations reverses some of the benefits of using a replica in the first place.

## Stage 3: a data warehouse

PostgreSQL and MySQL are OLTP (online transaction processing) databases, optimized for handling a high volume of short, fast reads and writes such as placing an order. On the other hand, data warehouses such as BigQuery, Redshift, and Databricks are OLAP (online analytical processing) systems, designed to answer analytical queries that process millions of rows. Our blog post on [OLAP vs OLTP](https://www.erathos.com/en/blog/olap-vs-oltp-analytics-vs-transaction-databases?utm_source=blog&utm_medium=organic&utm_content=bydefault&utm_campaign=read-replica-vs-data-warehouse) explains the differences between the two types of databases in more detail.

When it comes to reporting, data warehouses introduce three key differences.

First, data warehouses store data by column. A [columnar database](https://www.erathos.com/en/blog/what-is-an-analytical-database?utm_source=blog&utm_medium=organic&utm_content=bydefault&utm_campaign=read-replica-vs-data-warehouse) stores all values for a given column together, allowing a query for revenue to read only the date and amount columns and skip the rest of the table. A replica, on the other hand, must read all full rows in the table to answer the same question.

Second, data warehouses can split large tables into smaller parts. For example, a table can be partitioned by date, allowing queries for data from last month to read only data from last month. BigQuery uses [partitioning and clustering to reduce the amount of data processed by a query](https://cloud.google.com/bigquery/pricing), and the amount of data processed by a query is what BigQuery charges for.

Third, data warehouses charge for the amount of work done, as opposed to paying for a server that runs all day. BigQuery’s on-demand model charges $6.25 per TiB of data scanned, with the first 1 TiB per month being free. For those who want to pay a fixed price for compute, BigQuery editions charge per slot-hour, starting at $0.04 per slot-hour for the Standard edition. There are two important details about how BigQuery charges: BigQuery charges for all columns selected even when using a LIMIT clause, and BigQuery charges for at least 10 MB per table touched by a query.

Data warehouses can also contain more than one database. Replicas are limited to the databases that are on the primary, whereas data warehouses can store product databases alongside CRM, ERP, and advertising platform data. This allows users to join across signups, ad spend, and invoices in a single query. Erathos supports loading data from [databases and SaaS APIs](https://docs.erathos.com/introduction/quickstart?utm_source=blog&utm_medium=organic&utm_content=bydefault&utm_campaign=read-replica-vs-data-warehouse) into the same data warehouse.

## Read replica vs data warehouse: load, freshness, cost and joins

Here is how the three stages compare on the four things that drive the decision:

Stage

Load on production

Freshness

Cost model

Join other sources

Reports on production

Every report competes with customers for CPU, memory and disk

Live

No extra bill

No

Read replica

Close to none, but`hot_standby_feedback`can bring back bloat on the primary

Always a little behind, and further behind while long queries delay replay

A second instance billed per hour, used or not

No

Warehouse fed by CDC

Reading the log, plus the WAL a replication slot holds

Depends on the sync schedule, 5 minutes on Erathos Pro

Per TiB scanned, or per slot-hour

Yes

The cost row is hardest to compare between the two bills because they operate differently. Here is how they calculate costs with real numbers.

A db.r6g.xlarge PostgreSQL instance costs [$0.45 per hour in US East (Ohio)](https://aws.amazon.com/rds/postgresql/pricing/), on demand and Single-AZ. A replica of it bills at the same rate:

`Replica compute:  $0.45/hour x 730 hours          = $328.50/month`
`Replica storage:  500 GB gp3 x $0.115/GB-month    =  $57.50/month`
`Total:                                              $386.00/month`

Even at 3am when nobody’s looking at reports, you pay for the db instance for the whole month. If reports need the next size up, db.r6g.2xlarge ($0.899/hr) costs $656.27 per month just for compute.

The [BigQuery on-demand](https://cloud.google.com/bigquery/pricing) cost is $6.25 per TiB scanned, with the first TiB free per month.

**\[IMAGE 3: upload gtm-1478-img3.png here\]**

So the replica's compute bill buys this much scanning:

`$328.50 / $6.25 per TiB = 52.56 TiB`
`52.56 TiB + 1 free TiB  = 53.56 TiB scanned per month`

To make that concrete, take a made-up but realistic workload. A dashboard query reads 20 GiB after partitioning, and it runs 50 times a day:

`20 GiB x 50 runs x 30 days = 30,000 GiB = 29.30 TiB`
`(29.30 - 1 free TiB) x $6.25 = $176.86/month`

- Don’t forget to consider storage costs, though. Keeping 1 TiB of data in active storage for a full month in the us-central1 region will cost you about $23.55.
- The pricing of a warehouse like BigQuery can really get you, too. Scanning an unpartitioned 2 TiB table in a single query will cost you $12.50. If you have a dashboard that refreshes that query every 5 minutes, that’s 288 times a day, or $3,600 a day. The [same dashboard against a partitioned 50 GiB slice of the data](https://www.erathos.com/en/blog/olap-vs-oltp-analytics-vs-transaction-databases?utm_source=blog&utm_medium=organic&utm_content=bydefault&utm_campaign=read-replica-vs-data-warehouse) would cost you about $88 a day. Because pay-per-scan rewards the use of partitioned tables and penalizes full scans, a safety net of setting the maximum number of bytes billed for a single query is a low-cost option.
- A replica will cost the same amount every month, regardless of what you do with it. A warehouse, on the other hand, will cost you depending on how you use it and how you’ve partitioned your tables.

## When is it time to move analytics to a warehouse?

At some point, the replica isn’t cheaper and simpler than the problems it’s trying to solve anymore, and it’s time to switch to a warehouse. In the beginning, when a company only has one database and a small amount of data, they can run analytics [directly on top of their transactional database](https://www.erathos.com/en/blog/what-is-an-analytical-database?utm_source=blog&utm_medium=organic&utm_content=bydefault&utm_campaign=read-replica-vs-data-warehouse). You know you’re done with this stage when:

1. **You’re timing out reports** on months of history. If you need a report that looks at a year’s worth of data, and your only option is to increase the timeout, the row store is limiting you.
2. **The replica is canceling queries**. On PostgreSQL, you can use the `pg_stat_database_conflicts` view on the standby to find [the number of canceled queries and why they were canceled](https://www.postgresql.org/docs/current/hot-standby.html). If this number is increasing on busy tables, it means that reports and replication are fighting each other.
3. **Replica lag is breaking reports**. If you have a dashboard that compares yesterday’s numbers to today’s, or a finance report that misses the last hour of orders, then lag has become visible to the business.
4. **You enabled** `hot_standby_feedback` **and the primary is bloated**. Enabling this setting trades cancellations for table bloat on the primary, which brings back the Stage 1 problem.
5. **The BI tool needs to query multiple systems**. If someone asks for revenue by ad campaign, you need to query the database, the ad platform, and maybe the CRM. Since the replica only contains the database, someone’s going to have to manually combine spreadsheets.
6. **The replica keeps growing**. Every time reports slow down, you increase the instance class, which doubles the hourly rate each time you go up a size (db.r6g.xlarge to db.r6g.2xlarge goes from $0.45 to $0.899/hr).
7. **Departments are reporting different numbers**. Sales is reporting on data from the CRM and product is reporting on data from the replica, and the two numbers don’t match. A warehouse gives both teams [a place to access the same data](https://www.erathos.com/en/blog/what-is-a-data-warehouse?utm_source=blog&utm_medium=organic&utm_content=bydefault&utm_campaign=read-replica-vs-data-warehouse).

Two of these signs at once is a good point to start, and the replica can be kept alive while the warehouse slowly fills up. This eliminates the need for a cutover date.

## How data moves to the warehouse without loading production

One problem with SELECT queries is that they are scanning the same tables that your application is using for production, putting us back to Stage 1. However, PostgreSQL and MySQL already keep a log of all the changes they make. For PostgreSQL, this is the WAL, and for MySQL, it is the binlog. [A CDC (change data capture) process can read this log continuously through a logical replication slot](https://www.erathos.com/en/blog/cursor-based-sync-vs-change-data-capture?utm_source=blog&utm_medium=organic&utm_content=bydefault&utm_campaign=read-replica-vs-data-warehouse), picking up inserts, updates and deletes without querying the tables.

On PostgreSQL, CDC needs four settings:

`ALTER SYSTEM SET wal_level = 'logical';`
`ALTER SYSTEM SET max_replication_slots = 10;`
`ALTER SYSTEM SET max_wal_senders = 10;`
`ALTER SYSTEM SET max_slot_wal_keep_size = '5GB';`

The first three settings require a database restart. In MySQL CDC, binlog should be ROW with full row images. [MySQL deletes binlog files after 30 days by default](https://www.erathos.com/en/blog/mysql-cdc-to-bigquery?utm_source=blog&utm_medium=organic&utm_content=bydefault&utm_campaign=read-replica-vs-data-warehouse).

The last setting is the most important one. Replication slots can hold WAL files that the reader has not acknowledged yet. By default, replication slots [hold an unlimited amount of WAL files](https://docs.erathos.com/connectors/databases/postgresql). Therefore, if a reader stops consuming from the CDC pipeline, the WAL can grow out of proportion until the disk is full. Also, replication slots [can prevent VACUUM from removing certain rows](https://www.postgresql.org/docs/current/logicaldecoding-explanation.html). Setting a limit like 5GB can prevent a broken CDC pipeline from filling the disk.

To see how fast this adds up, we created a slot with no reader attached and inserted 100,000 rows into one table. This query shows what each slot is holding:

`SELECT`
`    slot_name,`
`    active,`
`    wal_status,`
`    pg_size_pretty(`
`        pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn)`
`    ) AS retained_wal`
`FROM pg_replication_slots;`

`  slot_name     | active | wal_status | retained_wal`
`------------------+--------+------------+--------------`
` erathos_cdc_demo | f      | reserved   | 38 MB`
`(1 row)`

With one single batch of insert, we generated 38 MB of data that can’t be deleted by PostgreSQL. On a busy production database, any unwatched slot will grow every hour. It’s better to add the query above to your monitoring.

After being read by the CDC, the changes are then bulk-loaded into the warehouse (as opposed to row-by-row). [Erathos moves data](https://docs.erathos.com/platform/how-we-move-data) in the following steps:

1. Extract the data from the source.
2. Write the data to temporary files on cloud bucket (S3, GCS or Azure Blob Storage) within Erathos infrastructure.
3. Load the data using `COPY` (or its equivalent in the destination) from those files into the warehouse.
4. Delete the temporary files when the job is done.

The whole path looks like this:

**\[IMAGE 4: upload gtm-1478-img4.png here\]**

The destinations can be [BigQuery, Redshift, Databricks and PostgreSQL](https://docs.erathos.com/introduction/quickstart). BigQuery allows us to batch load data from Cloud Storage [for free by default](https://cloud.google.com/bigquery/pricing). This means the load step won’t count towards your scan bill. CDC is available on the Erathos Pro plan with update frequency of 5 minutes.

## FAQ

**Can I keep the read replica after adding a warehouse?** Yes. The replica can still handle some of the workload a data warehouse can't, like serving read traffic from the app, and also [disaster recovery, since you can promote a replica to a standalone instance](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_ReadRepl.html). Once you shift your dashboards to a warehouse, you can size your read replica down because you'll no longer need to run any long-running reports there, and no reports will be cancelled.

**Does CDC put load on production?** A little, but much less than performing a copy of the database using a SELECT query. CDC just reads the database's log that's already being written to disk anyway. The overhead is a one-time snapshot, reading every table in full, when you start up a CDC pipeline. Then you get some overhead of the extra WAL data when the replica identity of some tables is full, and finally, the overhead of WAL data that can be held by a replication slot if the reader stops. You can limit that overhead by setting `max_slot_wal_keep_size`.

**How fresh will the warehouse data be?** The frequency of data changes in the warehouse is as good as the sync schedule. Even though CDC captures every change, [it does not have to mean streaming](https://www.erathos.com/en/blog/cursor-based-sync-vs-change-data-capture?utm_source=blog&utm_medium=organic&utm_content=bydefault&utm_campaign=read-replica-vs-data-warehouse), as changes are sent to the warehouse in batches. With CDC on the [Erathos Pro plan](https://www.erathos.com/en/pricing?utm_source=blog&utm_medium=organic&utm_content=bydefault&utm_campaign=read-replica-vs-data-warehouse), the warehouse is updated with the latest data every 5 minutes. On the other hand, the replica applies the changes as they come, so keep using the replica for any work that can't wait for the next warehouse sync.

## Try it on your own database

Already experiencing two or more of the above? [Try Erathos free for 14 days](https://app.erathos.com/signup?utm_source=blog&utm_medium=organic&utm_content=bydefault&utm_campaign=read-replica-vs-data-warehouse) and get full access to the Pro plan, including CDC from PostgreSQL or MySQL into BigQuery, Redshift or Databricks so you can compare your data warehouse against your replica.
