Database / Milvus Vector database Interview questions
When should you use IVF_PQ instead of IVF_FLAT?
Both start with the same clustering step, but they differ in how they store vectors within each cluster: IVF_FLAT keeps the full, uncompressed vector for exact comparison within a cluster, while IVF_PQ (Product Quantization) compresses each vector into a much smaller quantized representation, trading some accuracy for a significantly reduced memory footprint.
index_params.add_index( field_name="embedding", index_type="IVF_PQ", metric_type="L2", params={"nlist": 1024, "m": 16, "nbits": 8} )
IVF_PQ becomes the right choice specifically when a dataset is large enough that IVF_FLAT's memory footprint (storing every full vector) becomes a genuine constraint, and the application can tolerate the additional recall loss quantization introduces on top of the clustering approximation IVF_FLAT already makes. For datasets where memory isn't the binding constraint, IVF_FLAT (or HNSW) typically delivers better recall for a similar or even lower engineering effort, since quantization parameters (like m and nbits above) require their own tuning to get right.
More Related questions...