QuestDB vs ClickHouse: Which Fits Time Series Better? (SQL & Ingestion Compared)

QuestDB and ClickHouse are both columnar but built for different jobs: QuestDB for time-series ingest (ILP, SAMPLE BY, ASOF JOIN, partition retention), ClickHouse for general OLAP. This article compares table creation, ingestion, and downsampling side by side, and maps out where each wins, so you pick the right database for your data.

QuestDB vs ClickHouse: Which Fits Time Series Better?

“We already run ClickHouse — can’t we just write our time-series into it?” It is the single most common question in a time-series team. Both are columnar, both are fast, but their speed comes from opposite design choices. You can force a time-series workload into ClickHouse, yet you lose the time-aware syntax and write path QuestDB builds around; conversely, ClickHouse’s general OLAP breadth is not something QuestDB aims to cover. This article runs the same table-creation and downsample query on both engines and maps out exactly where each one wins.

1. Architectural intent: time-series-first vs general OLAP

QuestDB’s storage engine (Cairo) was designed around “time-ordered” from day one:

  • Tables are anchored on a designated timestamp column and sliced into directories by PARTITION BY period; cold partitions can be deleted outright.
  • It ships native time-series operators: SAMPLE BY (downsampling), LATEST ON (latest value per series), and ASOF / WINDOW / HORIZON JOIN (time-aligned joins).
  • Out-of-order data (O3) is handled in the engine — late rows are merged into their correct chronological position, so you never sort in the app layer.

ClickHouse is a general OLAP columnar engine built on the MergeTree family (MergeTree, SummingMergeTree, ReplacingMergeTree, and friends), with materialized views for pre-aggregation. It has no SAMPLE BY and no ASOF JOIN; time-series questions get solved with toStartOfInterval, argMin, any, or self-joins.

In one line: QuestDB makes “aggregate by time” a keyword; ClickHouse expects you to write the time logic yourself.

2. Table + ingest: the same data, two ways

Suppose one CPU-usage series. Here is how each engine models and ingests it.

QuestDB (time-series table + ILP line protocol):

CREATE TABLE cpu (
  ts    timestamp,
  host  symbol index=5,
  usage double
) PARTITION BY DAY;
# ILP ingest (port 9009, InfluxDB line protocol)
curl -X POST 'http://localhost:9009' -d 'cpu,host=srv01 usage=0.62 1759603200000000000'
curl -X POST 'http://localhost:9009' -d 'cpu,host=srv02 usage=0.41 1759603200000000000'

ClickHouse (MergeTree, partitioned by day):

CREATE TABLE cpu (
  ts    DateTime,
  host  String,
  usage Float64
) ENGINE = MergeTree
PARTITION BY toYYYYMMDD(ts)
ORDER BY (host, ts);
INSERT INTO cpu VALUES
  ('2026-10-04 16:00:00', 'srv01', 0.62),
  ('2026-10-04 16:00:00', 'srv02', 0.41);

The divide: QuestDB ingests over ILP or the binary QWP protocol, so clients push row after row; ClickHouse ingests over SQL INSERT and is far happier in large batches (it dislikes small, frequent writes). That is the core orientation — QuestDB is tuned for high-rate, small-batch time-series streams; ClickHouse is tuned for large-batch analytics.

3. Downsampling: one keyword vs an expression

“Downsample from 1-second to 1-minute, average per minute” reads like this on each side.

QuestDB (SAMPLE BY keyword, the intent is explicit):

SELECT
  ts,
  host,
  avg(usage) AS avg_usage
FROM cpu
SAMPLE BY 1m
FILL(none);

SAMPLE BY 1m buckets the timeline into 1-minute slices; FILL decides how empty buckets are handled (none, prev, linear, or a constant).

ClickHouse (expression + aggregate):

SELECT
  toStartOfInterval(ts, INTERVAL 1 MINUTE) AS ts,
  host,
  avg(usage) AS avg_usage
FROM cpu
GROUP BY ts, host
ORDER BY ts;

To take the latest value per bucket you reach for anyLast; to interpolate linearly you write it yourself, and argMin/argMax only aggregate a single column.

4. “Latest value per series”: LATEST ON vs a window function

“I want the newest row for each host”:

QuestDB (LATEST ON):

SELECT * FROM (
  LATEST ON ts PARTITION BY host SELECT * FROM cpu
);

ClickHouse (window function, or a ReplacingMergeTree pre-aggregate):

SELECT * FROM (
  SELECT host, usage, ts,
         row_number() OVER (PARTITION BY host ORDER BY ts DESC) AS rn
  FROM cpu
) WHERE rn = 1;

5. Where each wins (no marketing)

Pick QuestDB when the load is:

  • High-rate, small-batch time-series streams (IoT sensors, trading ticks, metrics, telemetry).
  • Native SAMPLE BY, LATEST ON, ASOF JOIN — the shorter the SQL, the better.
  • You need late/out-of-order rows merged automatically (O3), no app-layer sorting.
  • Single node or small cluster, where out-of-the-box write throughput matters.

Pick ClickHouse when the load is:

  • General OLAP: logs, event streams, user behavior, click streams — wide, varied schemas.
  • Rich materialized views, UDFs, cross-database joins, and cluster topology.
  • Large-batch ETL loads, not high-rate tiny writes.
  • Your team already runs ClickHouse’s materialized-view and cluster tooling.

Hybrid is common: hot time-series go to QuestDB (low-latency ingest + time queries), cold data and aggregate reporting sink into ClickHouse for wide-table analytics. They do not compete.

6. Three pitfalls

  • Do not use ClickHouse as a high-rate time-series sink: thousands of tiny INSERTs per second trigger constant merges and heavy write amplification.
  • Do not expect QuestDB to cover all OLAP: its strength is “by time”; complex cross-domain analytics and wide joins are still easier in ClickHouse.
  • Align timestamp semantics: QuestDB’s timestamp defaults to microsecond precision, while ClickHouse DateTime/DateTime64 differ; wrong unit on cross-engine sync is wrong data.

7. Next steps

References

📺 Watch video tutorials → Time-Series Lab YouTube

Subscribe for more QuestDB & time-series tutorials