I'm hitting a persistent error when querying my Chroma DB collection: Cannot return the results in a contiguous 2D array. Probably ef or M is too small. This only happens when I request n_results > 50. I’m using the HNSW index—what are the safe production values for these parameters in 2026?
3 answers
This error happens when the HNSW graph is too "sparse" to find the number of neighbors you're asking for. In Chroma, you should increase M (max connections per node) and ef_construction during the collection creation. For a production set of 1M+ vectors, I usually recommend M=32 and ef_construction=200. It makes the indexing slower and uses more memory, but it fixes the "contiguous array" crash and significantly improves your search recall.
Does increasing these values impact the query speed (latency) significantly?
You can also try reducing the number of results you request. If you're using a RAG pipeline, do you really need more than 10-20 context chunks?
We were trying to do a "bulk" similarity analysis, Charles. But following Angela's advice on the HNSW parameters completely solved the crash. Thanks!
ef_search is the one that hits query speed. M and ef_construction mostly affect the build time and index size. If you keep ef_search around 100, you’ll get a good balance of accuracy and speed in Chroma.