ClickhouseDb class.
Why ClickHouse only for traces
ClickHouse is an OLAP columnar engine. It is designed for the workload traces actually produce:- Append-heavy ingest. Spans arrive continuously. ClickHouse inserts coalesce into large columnar parts.
- Time-bucketed aggregates. Trace dashboards group by minute, hour, day. Columnar storage scans only the columns the query touches.
- Low-cardinality filters. Filtering by
statusorspan_kindover billions of rows is whatLowCardinality(String)is built for. Filtering byagent_id/session_idscans one narrow column instead of whole rows. - Cheap retention.
PARTITION BY toYYYYMM(start_time)lets you drop a month of traces with oneALTER TABLE.
Session and memory storage hit all three of those patterns, which is why Agno uses a row-store for them and reserves ClickHouse for tracing.
Usage
Install the required packages:clickhouse_for_traces.py
Run ClickHouse
Install Docker Desktop and run ClickHouse on port 8123 (HTTP) and 9000 (native) using:cookbook/scripts/run_clickhouse.sh.