{"slug": "just-brute-force-your-vector-search", "title": "Just brute force your vector search", "summary": "A software engineer argues that brute-force vector search with numpy can outperform vector databases for many use cases, citing benchmarks showing 79.7 queries per second on 1 million 384-dimension embeddings on a MacBook Pro. The post, referencing Raymond Chen and Jo Kristian Bergum, suggests teams with ~1 million documents and low query traffic may not need the complexity of a dedicated vector database.", "body_md": "When I wrote embedded C code in the 2000s we latched onto something [Raymond Chen, wrote in passing](https://devblogs.microsoft.com/oldnewthing/20050622-49/?p=35223)\n\nMy O(n) algorithm can run circles around your O(log n) algorithm; why much of what you learned in school simply doesn’t matter\n\nTrue of a sorting algorithm. True of vector search.\n\nPeople think they need a vector database. But often the number of vectors to search turns out to be low. And numpy can brute-force an array of float32s very fast:\n\n| Index Size | Client Threads | QPS | Avg Latency |\n|---|---|---|---|\n| 1000000 | 1 | 79.7 | 0.012s |\n| 1000000 | 10 | 170.5 | 0.058s |\n| 8841823 | 1 | 9.34 | 0.106s |\n| 8841823 | 10 | 18.34 | 0.106s |\n\nThis is literally 3 lines of Python code, on 384 dim embeddings, running on my MBP.\n\n```\n# Dot product against all\nscores = self.doc_vectors @ query_vector.astype(np.float32, copy=False)\n\n# Get top K most similar\nranked_indexes = np.argpartition(scores, -top_k)[-top_k:]\nscores = scores[ranked_indexes]\n\n# Now sort scores / ranked_indexes\nranked_indexes = ranked_indexes[np.argsort(-scores, kind=\"stable\")]\nscores = scores[np.argsort(-scores, kind=\"stable\")]\n```\n\nI work with a lot of teams that don’t need the complexity of a vector database. They have ~1m documents to search. They have low query traffic, and write their embeddings all up front. They don’t need to buy a multi-million dollar vector database, or spend 6 months learning to operate it.\n\nFor low enough n, just brute force the embeddings until you can’t bear to. As fellow search traveler Jo Kristian Bergum says [“an exhaustive search may be all you need”](https://bergum.medium.com/four-mistakes-when-introducing-embeddings-and-vector-search-d39478a568c5).\n\nAs a footnote, this is just naive numpy operations, it could probably be faster. As [Andreas Erickson says](https://x.com/andreer/status/2082531919233761580), throughput can be improved here by giving threads more than one query during the scan). And we could be doing a lot more during the search to collect into a top-n heap than what numpy does.\n\n### Upcoming course: Build your own vector database\n\nWant to understand what makes embedding retrieval fast, relevant, and useful in real AI systems? Join [Build your own vector database](https://maven.com/softwaredoug/vectordb) and build the core pieces yourself, from embeddings and indexing to search and retrieval.", "url": "https://wpnews.pro/news/just-brute-force-your-vector-search", "canonical_source": "http://softwaredoug.com/blog/2026/07/29/just-brute-force-embeddings.html", "published_at": "2026-07-29 00:00:00+00:00", "updated_at": "2026-07-29 21:54:52.964277+00:00", "lang": "en", "topics": ["artificial-intelligence", "developer-tools"], "entities": ["Raymond Chen", "Jo Kristian Bergum", "numpy", "MacBook Pro"], "alternates": {"html": "https://wpnews.pro/news/just-brute-force-your-vector-search", "markdown": "https://wpnews.pro/news/just-brute-force-your-vector-search.md", "text": "https://wpnews.pro/news/just-brute-force-your-vector-search.txt", "jsonld": "https://wpnews.pro/news/just-brute-force-your-vector-search.jsonld"}}