Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

ClickHouse 20 min read Deep dive hardMaster

We built a vector search engine that lets you choose precision at query time

QBit is a new ClickHouse column type that stores BFloat16, Float32 or Float64 vectors as transposed bit planes, each held in a FixedString subcolumn. Vector search can then read only the top N bit planes and choose precision at query time, trading recall for I/O and compute without duplicating data or committing to irreversible quantisation. Distance functions like L2DistanceTransposed reconstruct truncated floats with AVX-512 SIMD untransposition, and downcast only the reference vector when the bit layout matches, as with Float32 to BFloat16. Search remains O(n), so HNSW is still faster when its index fits in RAM.

Assumes: vector embeddings and similarity searchIEEE-754 floating pointSIMD vectorizationcolumnar databases

Related posts

  • Vector Search with ClickHouse - Part 2

    ClickHouse mediumAdept

    ClickHouse can serve as a vector store by keeping embeddings in Array(Float32) columns and computing distance functions in SQL. The walkthrough uses the 2.2-billion-row English LAION dataset of CLIP ViT-L/14 image and caption embeddings, covering schema design, loading from S3 Parquet, compression, and exact linear-scan search combined with metadata filtering and aggregation. It also covers the experimental Annoy ANN index, UDFs for generating query vectors, and codec tuning. ClickHouse fits best when vector matching needs SQL filtering, joins or aggregation over datasets too large for memory. Dedicated vector databases or in-memory indexes suit small, very high-QPS workloads better.

  • What's new in pgvector v0.7.0

    Supabase mediumAdept

    pgvector 0.7.0 adds float16 (halfvec), sparse and bit vector types to exploit redundancy in embeddings and cut memory and storage. Halfvec halves both table and HNSW index size (3.5GB vs 7GB for 900K 1536-dim OpenAI vectors) and builds parallel HNSW indexes about 30% faster, with Jonathan Katz's benchmarks showing up to 3x faster builds at essentially unchanged recall and QPS. Binary quantization with Hamming-distance HNSW indexes enables a fast pre-select followed by exact re-ranking on a small subset, with limit sizes tuned per dataset. The release also adds L1, Hamming and Jaccard distance operators and index opclasses.

  • Binary and Scalar Embedding Quantization for Significantly Faster & Cheaper Retrieval

    Hugging Face mediumAdept

    Quantizing embeddings themselves, rather than model weights, sharply cuts retrieval memory, disk and cost. Binary quantization thresholds normalized float32 values at 0 to give 32x smaller vectors searched by Hamming distance, while scalar int8 quantization uses per-dimension min/max ranges from a calibration set to give 4x savings. On MTEB retrieval, mxbai-embed-large-v1 keeps about 96% of NDCG@10 with binary embeddings plus float32-query rescoring, and 97% with int8. A combined pipeline does a binary in-memory search, then rescores the top candidates with int8 embeddings loaded from disk, serving 41M Wikipedia texts with 5.2GB of memory instead of about 200GB. Sentence Transformers code and vector database support tables are included.

  • Don’t use vector. Use halvec instead and save 50% of your storage cost

    Neon mediumAdept

    pgvector 0.7's half-precision halfvec type stores embedding components as 16-bit floats instead of 32-bit, cutting table and HNSW index storage nearly in half. On a 1M-row, 1536-dimension DBpedia dataset on an 8 CPU Neon Postgres instance (HNSW m=32, ef_construction=256), it also reduced index build time by 23% and prewarming time by 50%, with equivalent query latency and recall. Binary quantization shrinks vectors 32x and speeds index builds, but its recall on 1536-dimension embeddings was too low for production. The recommendation is to prefer halfvec over vector after testing on your own data.

  • Vector Search with ClickHouse - Part 1

    ClickHouse easyNovice

    Vector search replaces term-based inverted indexes, which use TF/IDF or BM25 scoring and can't capture meaning or handle vocabulary mismatch, with embeddings: arrays of floats where semantically similar text, images or audio sit close together under cosine or Euclidean distance. Exact KNN linear search compares the query against every vector in O(n) and rarely scales past ~100M vectors without heavy parallelism or GPUs. Approximate nearest neighbour methods such as HNSW and Annoy give up some recall for speed. Annoy, for example, recursively partitions space into a tree and only scans the leaf nearest the query. ClickHouse stores vectors as Array(Float32) columns with distance functions, and embeddings are typically generated by transformer models such as BERT or by CNNs and ViTs for images.

The quest for software engineering knowledge.

Look:
Layout: