Real-time petabyte analytics without DB impact


How to analyze petabytes of data in real time without slowing down your production database?

 

Growing apps all hit the same inflection point, where a business wants to query a PostgreSQL or MySQL database with petabytes of data, in a way it was never designed for.

The result: a dashboard query that should take 200ms takes 40 seconds as analytics scans 500M rows, crushing CPU and I/O. Users wait too long for query results, and in the end the entire SLA agreement hangs in the balance.

It's not a problem you can fix with tuning, instead it requires a change in architecture: you need to stop running heavy queries on your production database.
In this article you'll learn the architecture pattern for separating OLTP from OLAP, how to stream data safely into ClickHouse, and why OVHcloud managed service is the right fit for SaaS, FinTech, AdTech, and e-commerce teams scaling to billions of rows.

Why your production database is the wrong place to run analytics

A production Public Cloud database instance is built for transactions, not analytics. When business teams start asking for real-time dashboards, fraud detection, or customer segmentation queries against terabytes of historical data… well, performance collapses.
That happens not so much because infrastructure is weak, but because the app is using the wrong tool for the job.

OLTP vs OLAP

OLTP (online transaction processing) and OLAP (online analytical processing) sit at opposite ends of the data architecture spectrum.

OLTP systems prioritize correctness and transaction-level precision, handling thousands of small, fast writes and reads per second.They store data row by row, optimized for looking up a single customer record or updating an order status in milliseconds.

OLAP systems, by contrast, are designed to scan trillions of rows for complex aggregations. They use columnar storage, where each column is stored independently. This means when you query SUM(revenue) WHERE date > '2025-01-01', the database reads only the revenue and date columns, skipping everything else. So, for example in ClickHouse, operations run in vectorized execution. ClickHouse processes entire arrays of values at once rather than individual rows, which dramatically reduces CPU overhead and maximizes cache utilization.

No amount of data indexing, query optimization, or hardware upgrades will make a row-oriented database efficient at columnar scans. The architectures are fundamentally different.

Why read replicas won't solve the problem

Read replicas in Public Cloud Databases are the most common first response to analytics pressure on production databases. They offload read traffic from the primary node, but they don't fix the architectural mismatch.

A read replica might reduce contention on your primary database, but when you run SELECT SUM(revenue), COUNT(*) FROM events WHERE date >= '2024-01-01' across 500M rows, the replica still reads and discards almost every row.

These analytics queries compete with production transactions for CPU, memory, and I/O. App latency rises, SLAs are at risk, and real-time use cases like fraud detection or anomaly monitoring become impossible.

The 40-second query that should take 200 ms

Here's the typical scenario for a SaaS scale-up or FinTech platform company hitting the data inflection point. A query runs, intended to aggregate daily revenue by customer segment over 18 months (500M rows),

The expected time for execution under the OLAP domain model is 200 ms, but the actual time under the OLTP platform ends up being 40 seconds. Why? Well this is what happens in the background:

  • Full table scan : The PostgreSQL/MySQL platform must read all 500M rows because the index doesn't help with wide aggregations.

  • Row-by-row processing : Each row is decompressed, parsed, and evaluated individually.

  • I/O bottleneck: Disk reads dominate—most of the data read is discarded.

  • CPU waste : CPU cycles spent on row parsing instead of aggregation quality.

  • Memory pressure : Large sorts and hash joins spill to disk.

The business impact is immediate and compounding, because what should be an hourly data dashboard can, in practice, only be generated once a day, delaying business decisions.
Business decisions are delayed because minute-by-minute analytics becomes too expensive, and real-time features become impossible at scale.And that matters – real-time responsiveness is essential for use cases such as fraud detection, personalization, and anomaly monitoring. These use cases are not viable with 40-second query latency.

The architecture pattern: separating OLTP from OLAP

The solution is architectural separation: run transactions on an OLTP database instance and stream data into a separate OLAP instance built for scanning billions of rows in sub-second time. Each system does what it was designed for, without compromising the other.

Columnar storage and vectorized execution explained

PostgreSQL and MySQL store data row by row, which makes sense for engineering transactions retrieving single records but terrible for analytics aggregating one column across billions of rows. ClickHouse stores data by column instead.

When you query SUM(revenue) across 5 billion rows, it reads only the revenue column, skipping everything else. This reduces I/O by 90% or more and enables aggressive compression since values in a column are similar.

Vectorized execution is the second multiplier. Traditional databases process one row at a time. ClickHouse processes entire arrays of values at once, loading a chunk of the revenue column into CPU cache and applying operations across the entire vector volume in a single instruction. This dramatically reduces CPU overhead.

The combination enables sub-second queries on billions of rows. Columnar storage minimizes disk reads; vectorized execution minimizes CPU work. ClickHouse can aggregate 10 billion rows in under a second while a PostgreSQL instance takes minutes.

Materialized views: pre-aggregation at ingest time

Even with columnar data storage, scanning raw data every time is expensive. Materialized views pre-compute aggregates at ingest time.

In ClickHouse, a materialized view is an active pipeline, not a passive snapshot. When you insert data, ClickHouse automatically evaluates the view's query and writes results to a separate table.

If you're ingesting 100,000 events per second with a view aggregating by minute and segment, ClickHouse computes those aggregates in real time.

Your dashboard queries the pre-aggregated table instead of scanning raw events. This shifts cost from query time to ingest time, accepting small write overhead for instant query response. For minute-by-minute dashboards and fraud detection, materialized views eliminate latency between data arriving and being queryable.

They also enable multi-resolution analytics: keep raw data for forensics while maintaining hourly/daily aggregates for dashboards. As data ages, query coarser aggregates, keeping performance consistent as you scale from terabytes to petabytes.

Tiered storage to keep costs linear at petabyte scale

Storing petabytes on SSDs is prohibitively expensive. Tiered storage moves older data to cheaper object storage while keeping recent data on fast local disks.

For example, OVHcloud Managed ClickHouse implements this natively in tools with OVHcloud Object Storage (S3-compatible)* stream processing. Recent data (30–90 days) stays on stream on NVMe SSDs.

Older data automatically migrates to an OVHcloud Object Storage bucket at a fraction of the cost, still enabling fast queries since ClickHouse reads only needed columns. Costs for engineers stay linear as you scale: each additional terabyte costs the same at 10 TB or 100 TB.

ClickHouse queries OVHcloud Object Storage data without Athena, Presto, or Spark. Hot data on SSD, cold data on S3, all through the same SQL interface. This eliminates maintaining separate systems for hot and cold based data.

Tiered storage also simplifies long-term data retention: keep raw data indefinitely for compliance without breaking the bank. Query 18-month-old data for investigations? ClickHouse reads it from OVHcloud Object Storage S3*, which is slower but still fast enough for ad-hoc analysis.

How to feed data into your analytical layer

Once you've separated the OLTP instance from OLAP tools, you need to move data from your production database into ClickHouse. There are three main patterns, each with different trade-offs in latency, complexity, and operational overhead.

Batch ETL with Airflow, dbt or cron jobs

Batch ETL is the simplest starting point. Extract data from your production database on a schedule (hourly or daily), transform it with dbt, and load it into ClickHouse. Airflow orchestrates the pipeline, or cron jobs handle simple scripts.

This works when you don't need minute-by-minute freshness. Hourly dashboards are fine for many business cases, and batch processing is easier to debug and monitor. Failed jobs retry on the next schedule, and backfilling historical data is straightforward.

The trade-off is the latency you create. Data is stale between batches, so real-time fraud detection or live personalization aren't possible. You're also running heavy extract queries on production during the batch window, which can cause contention if not scheduled during low-traffic periods. Batch ETL is right when you're starting with ClickHouse, lack streaming expertise, or tolerate hour-old data.

Real-time CDC with Apache Kafka and Debezium

Change Data Capture (CDC) streams every insert, update, and delete from production to ClickHouse in near real-time. Debezium reads your database's transaction log (WAL for PostgreSQL, binlog for MySQL) and publishes changes to Apache Kafka. ClickHouse consumes from Kafka and inserts immediately.

CDC tools achieve sub-second to low-second latency, enabling true real-time data analytics: fraud detection that detects and blocks transactions as they happen, anomaly monitoring that alerts within seconds, personalization that reacts instantly to support user behavior.

While setup complexity is higher, CDC is the standard for real-time analytics at scale. The overhead is justified when business decisions depend on data freshness. Many teams use managed Kafka to reduce burden, or start with batch and migrate to CDC once real-time value is validated.

Direct application writes efficiently for purely event-driven workloads

Your application writes directly to ClickHouse tools alongside your critical OLTP database. This works best for event-driven workloads where every user action is an event worth analyzing: page views, clicks, API calls, sensor data. The application sends the event to both systems in parallel, or uses ClickHouse as primary and syncs to PostgreSQL for transactions.

This eliminates the ETL layer entirely. No Kafka, no Debezium, no batch jobs. The application writes once, data is immediately queryable, and latency is minimal.

Why ClickHouse is the right OLAP engine for real-time analytics

ClickHouse was built from the ground up for real-time analytics on massive datasets. Unlike general-purpose data warehouses that optimize for batch workloads or if you or those optimizing for interactive BI, ClickHouse prioritizes sub-second query latency even when scanning billions of rows.
This makes it the right choice for SaaS, FinTech, AdTech, and e-commerce companies that need analytics that keep pace with their production systems.

Sub-second query performance
ClickHouse achieves sub-second latency on queries scanning billions of rows thanks to columnar storage, vectorized execution, and aggressive compression. It can aggregate 10 billion rows in under a second while PostgreSQL takes minutes and other warehouses take seconds to tens of seconds.

ClickHouse vs Redshift vs BigQuery
ClickHouse delivers stable, resource-based pricing with high concurrency and efficient scaling, ideal for interactive real-time analytics. Redshift is best for batch-oriented data warehousing with predictable workloads and existing AWS infrastructure. BigQuery excels at serverless analytics with sporadic queries and teams that want zero operational overhead.

Icons/concept/Database/Database SQL Created with Sketch.

ClickHouse SQL
ClickHouse uses a SQL dialect that's 90% compatible with the standard SQL development experience, but key differences exist. Aggregate functions use MergeTree tables with specific engine syntax. Most SELECT queries translate directly, but complex JOINs and subqueries may need optimization.

Migration tips to manage include testing queries on a representative host dataset first, using ClickHouse's EXPLAIN to optimize session execution plans, and leveraging materialized views to pre-compute complex tool stack aggregations.

Why choose OVHcloud Managed ClickHouse

OVHcloud Managed ClickHouse is the only native managed ClickHouse offered by a European cloud provider, alongside our established Managed Databases for PostgreSQL . This means no third-party data routing, no dependency on ClickHouse Cloud, and no inter-provider data flows.

  • Managed ClickHouse from an EU provider: OVHcloud is the only European region cloud provider offering a native managed ClickHouse engine. Unlike competitors where you'd route through third-party services, OVHcloud runs ClickHouse directly on its infrastructure.

  • Automatic to OVHcloud Object Storage: Cold data automatically migrates to S3-compatible* OVHcloud Object Storage, keeping costs linear at petabyte scale. Recent data (30–90 days) stays on NVMe SSDs for maximum speed, while older data moves to OVHcloud Object Storage at a fraction of the cost. Crucially, there are no egress fees. 

  • 3-AZ deployments in Paris and Milan : Production clusters run across three availability zones in Paris or Milan with 99.99% SLA in 3 A-Z, 24/7 technical support included, and multi-node replication for high availability. The Gen3 service (since August 2025) delivers 5× storage, 4× bandwidth, 2× TPS, and 1.5× faster startup compared to previous generation; all of which is better for scaling.

  • GDPR by design, no Cloud Act exposure : OVHcloud is a French company under French/EU law only. All analytical data stays in European data centers, with no Cloud Act exposure that affects US providers. This is especially relevant for behavioral data, financial transactions, and GDPR-scoped data.

Plus, OVHcloud’s services are ISO/IEC 27001/27017/27018/27701 certified and HDS compliant, with SecNumCloud in progress. That includes our Managed Apache Kafka for CDC pipelines and our OVHcloud Object Storage (S3-compatible)*.
For European SaaS, FinTech, AdTech, and e-commerce companies handling EU customer data, this sovereignty guarantee eliminates the legal risk of US authorities accessing data stored with American cloud providers.

Get started: deploy ClickHouse and connect it to your production database

Ready to free your production database from heavy analytics queries? Deploying OVHcloud Managed ClickHouse takes just minutes through the control panel or API.
We ensure your data stays in European data centers to ensure privacy and full observability, with no egress fees, and tiered storage to OVHcloud Object Storage S3-compatible* ensures costs stay predictable as you scale from terabytes to petabytes.
Start your ClickHouse cluster your ClickHouse software cluster today and see why over 2,000 companies including Tesla, Bloomberg, and Anthropic rely on ClickHouse for real-time analytics.

*S3 is a registered trademark of Amazon Technologies, Inc. OVHcloud services are not sponsored or approved by, nor affiliated with Amazon Technologies, Inc. in any way.