---
title: "Accelerating ClickHouse queries on JSON data for faster Bluesky insights"
description: "Incremental materialized views feeding AggregatingMergeTree tables cut ClickHouse dashboard queries over 4+ billion Bluesky JSON documents (1.6 TiB) from 44–56 seconds to 3–7 ms. Partial aggregation states are computed only for newly inserted rows and merged in the background, so the pre-aggregated tables stay tiny (e.g. 892 rows, 11 KiB) and constant-size regardless of source growth."
url: "https://swe.quest/articles/accelerating-clickhouse-queries-on-json-data-for-faster-bluesky-insights-cce6ed7a467f6449"
canonical: "https://clickhouse.com/blog/accelerating-clickhouse-json-queries-for-fast-bluesky-dashboards"
source: "ClickHouse"
published: "2025-03-19"
difficulty: "medium"
kind: "How-to"
reading_minutes: 29
tags: ["analytics","performance","sql","databases"]
---

# Accelerating ClickHouse queries on JSON data for faster Bluesky insights

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2025-03-19, 29 min read, How-to. Original: [https://clickhouse.com/blog/accelerating-clickhouse-json-queries-for-fast-bluesky-dashboards](https://clickhouse.com/blog/accelerating-clickhouse-json-queries-for-fast-bluesky-dashboards)

## Summary

Incremental materialized views feeding AggregatingMergeTree tables cut ClickHouse dashboard queries over 4+ billion Bluesky JSON documents (1.6 TiB) from 44–56 seconds to 3–7 ms. Partial aggregation states are computed only for newly inserted rows and merged in the background, so the pre-aggregated tables stay tiny (e.g. 892 rows, 11 KiB) and constant-size regardless of source growth. Query latency therefore stays flat as the source table grows, and memory drops from ~776 MiB to ~186 KiB per query. Three dashboard scenarios cover count, uniq-based unique-user counts and top-reposted posts, with DDL, materialized view definitions and execution statistics; the reposts dashboard runs with a 5-second delay.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [SQL](https://swe.quest/tags/sql.md) (Languages)
- [Databases](https://swe.quest/tags/databases.md) (Data & databases)

## Prerequisites

- SQL aggregation ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- ClickHouse MergeTree basics ([easy posts on Analytics & OLAP](https://swe.quest/tags/analytics.md?difficulty=easy))
- materialized views

## Keywords

ClickHouse, Bluesky, AggregatingMergeTree, materialized views, JSON type, ClickHouse Cloud

## Related posts

- [Harnessing the Power of Materialized Views and ClickHouse for High-Performance Analytics at Inigo](https://swe.quest/articles/harnessing-the-power-of-materialized-views-and-clickhouse-for-high-performance-ebcfa2d951da7c43.md): ClickHouse · 2023-06-23 · Medium · 8 min read · Analytics & OLAP, Databases, SQL, Performance engineering
  Inigo stores analytics on billions of GraphQL API requests in ClickHouse after rejecting Snowflake as too slow and costly for customer-facing data and lacking a local emulator, and PostgreSQL because its indexes and costs blew up past roughly 100K–1M rows.
- [Building a product analytics solution with ClickHouse](https://swe.quest/articles/building-a-product-analytics-solution-with-clickhouse-786424348993d92f.md): ClickHouse · 2024-12-05 · Medium · 24 min read · Analytics & OLAP, SQL, Databases, Product engineering
  ClickHouse's in-house product analytics platform, Galaxy, stores over 20 billion events (14 TB, roughly 14x compression) in a single denormalized MergeTree table keyed on created\_at.
- [Better Analytics at Scale with Trackingplan and ClickHouse](https://swe.quest/articles/better-analytics-at-scale-with-trackingplan-and-clickhouse-fe79c2efef76743f.md): ClickHouse · 2024-01-24 · Medium · 6 min read · Analytics & OLAP, Databases, Multi-tenancy, Cloud platforms
  Trackingplan, which tests web, mobile and backend analytics by sampling events sent to tools like Google Analytics and Segment, moved from DynamoDB with PySpark-precomputed statistics to ClickHouse Cloud so it could answer unforeseen ad hoc queries on raw data.
- [ClickHouse Newsletter April 2022: JSON, JSON, JSON](https://swe.quest/articles/clickhouse-newsletter-april-2022-json-json-json-d21f592453b8c7ef.md): ClickHouse · 2022-04-14 · Medium · 5 min read · Analytics & OLAP, Databases, SQL
  ClickHouse 22.3 LTS adds an experimental JSON data type that stores semi-structured documents in a single column, with dynamic subcolumns underneath, so you no longer need hand-built schemas of arrays and materialized columns.
- [ClickHouse Release 23.12](https://swe.quest/articles/clickhouse-release-23-12-36e0c0d21cc33770.md): ClickHouse · 2024-01-11 · Medium · 16 min read · Analytics & OLAP, Query engines, SQL, Performance engineering
  ClickHouse 23.12 adds experimental Refreshable Materialized Views, which periodically re-run an arbitrary query and atomically replace the results in a target table.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
