How Instacart Built a Modern Search Infrastructure on Postgres

Ankit Mittal, Vinesh Gudla, Guanghua Shu, Akshay Nair, Tejaswi Tenneti, Andrew Tanner28 May 2025

Problem

Instacart search serves millions of requests a day over billions of items from thousands of retailers. Prices, availability and discounts change several times a day, so the search and ranking database takes billions of writes per day. The team ran full-text retrieval and embedding retrieval as separate stacks and merged them in the application. This forced overfetching and post-filtering, gave no fine control over precision and recall, and added operational burden.

Example from the article: a query like "pesto pasta sauce 8oz" is served best by keyword retrieval, while "healthy foods" needs semantic retrieval.

Solution in brief

Instacart moved text retrieval to sharded, normalized Postgres (GIN indexes, a modified ts_rank), then replaced the standalone FAISS service with pgvector in the same Postgres. Both retrieval modes now run in one engine, and live availability data filters the vector search before it runs. A production A/B test showed 6% fewer searches with zero results.

Questions this case answers
  • How to run lexical and dense retrieval in a single store so that attribute filters apply before the nearest-neighbor search and the recall set can be tuned
  • How to serve retrieval over a catalog whose records are rewritten constantly without the indexing load degrading read latency
  • How to combine keyword and embedding retrieval in one datastore instead of merging two services in the application?
  • How to keep a search index fresh when prices and availability change billions of times a day?

Tools and methods

  • PostgreSQL — single store for catalog, ML features, availability, full-text and vector retrieval
  • GIN indexes with a modified ts_rank — text matching inside Postgres
  • pgvector (HNSW) — approximate nearest neighbor search on embeddings next to the text index
  • FAISS — the earlier standalone ANN service, replaced by pgvector
  • Bi-encoder (Hugging Face MiniLM-L3-v2 architecture) — query and document embeddings
  • Elasticsearch — the original text search, replaced because of write load
Continue reading — it's free

Google or a one-time email code. No password.