January 18, 2026·5 min read·Databases

Processing Millions of Events Under 50ms with ClickHouse and Next.js

Why traditional relational databases fail at high-throughput analytics, and how pairing columnar event stores with Server Components produces lightning-fast dashboards.

The Analytical Bottleneck

PostgreSQL is phenomenal for transactional workloads. But when you ask it to compute a distinct count of 15 million user sessions grouped by country, referrer, and custom metadata, row-oriented disk reads quickly become a bottleneck.

In analytical systems, queries rarely need all columns; they need to scan hundreds of millions of rows across three or four specific fields. This is where columnar databases like ClickHouse change the game entirely.

Columnar Storage and Vectorized Execution

Because ClickHouse stores data column-by-column rather than row-by-row, scanning a single integer column across 20 million rows requires reading only a fraction of the disk bytes. Coupled with aggressive compression (frequently exceeding 15x over raw JSON), disk I/O ceases to be the bottleneck.

Furthermore, vectorized SIMD execution allows the CPU to aggregate multiple records in a single instruction cycle, routinely delivering query times under 40 milliseconds for datasets that would cause relational databases to timeout.

Rendering Without Client-Side Bloat

The final piece of high-performance analytics is presentation. In legacy SPAs, developers often fetch raw arrays of thousands of data points to the browser, relying on massive charting libraries that freeze the main thread.

With Next.js App Router and Server Components, all aggregation happens right on the database layer and server runtime. The client receives pre-computed SVG coordinates and pure HTML tables, keeping the client bundle tiny and first paints instantaneous.