Skip to content

Approx vector search in ClickHouse

YouTube Video: sBQiHWl3qYw

Mark Needham

Looking to speed up your vector similarity searches in ClickHouse? This video walks through approximate vector search using HNSW indexes, which can dramatically reduce query times compared to linear scans. We'll work with a dataset of nearly a million Wikipedia entries, showing you how to set up vector similarity indexes and when to use different distance functions.

We start with a basic linear scan approach using L2 distance, then introduce vector similarity indexes that bring query times down from seconds to milliseconds. You'll see practical examples using both L2 and cosine distance functions, and learn when each one makes sense for your data. We also cover filtering strategies—pre-filter versus post-filter—and how ClickHouse's query engine decides which approach to use based on heuristics.

  • Setting up vector similarity indexes with HNSW on embedding columns
  • Comparing L2 distance (Euclidean) vs cosine distance for similarity calculations
  • Performance differences between linear scan and approximate search methods
  • Adding WHERE conditions to vector searches and understanding filter strategies
  • Controlling pre-filter vs post-filter behavior with vectorSearchFilterStrategy setting

Recent videos

YouTube Video: e-NnqMTY_3A

How to

Inspect incoming data with INSERT … RETURNING in ClickHouse

Use INSERT … RETURNING in ClickHouse 26.11 to inspect generated values, sample incoming rows, find invalid ratings, and summarise an ingestion batch.

YouTube Video: BsmTK-pa5ks

How to

Reading and writing Vortex files with ClickHouse (26.11)

Query and export Vortex files with ClickHouse 26.11, using a FineWeb dataset containing just over a million web pages.

Follow us

XBlueskySlackGithubTelegramMeetupRSS