We'd like to welcome Contentsquare as a guest to our blog. At Contentsquare, they used to run their main SaaS application on top of Elasticsearch 5 years ago, when they started migrating all their analytics applications to ClickHouse to improve horizontal scalability, stability, and efficiency. They chose ClickHouse over Elasticsearch because it offered minimal latency for queries, rich query language, fast and efficient performance with spinning disks, and simple deployment and operation. Contentsquare split their migration effort into three phases: building a new product to get familiar with the technology, mirroring existing features with custom tooling, and migrating clients one by one. They built automation and CI/CD tooling for ClickHouse deployments and set up alerting and monitoring. The migration allowed Contentsquare to reduce infrastructure costs by 11 times, improve performance by 10x, and increase data retention periods. Contentsquare made two major adaptations to their architecture: a custom ingestion component and representing queries as abstract syntax trees. They also implemented an optimized ingestion pipeline using Kafka and a clickin component to handle insertions. The query optimizer simplified redundant expressions and reduced slow queries by 10x. Contentsquare's experience highlights the importance of automation, understanding MergeTree engines, and making data in a single shard for efficient scalability.