Read along with the audio summary
Ankit Mittal, a former Senior Engineer at Instacart, points out an early efficiency problem with their product search: almost everything retrieved had to be filtered out. In this episode from September 17, 2025, Ankit discusses the evolution of Instacart's product search architecture and their migration from a standard Elasticsearch setup to a customized PostgreSQL cluster. By the end, you will learn the principles, data pipelines, and trade-offs behind turning a database into a search engine.
Combining text search with real-time data solves the problem of broad, inefficient retrieval. When a search retrieval is too broad, it forces the application to do heavy filtering, which is inefficient and leads to multiple network calls. Instacart's search system addressed this through hybrid search retrieval. It combined traditional text search with complex, real-time filtering and personalized ranking, all based on rapidly changing data like inventory and user preferences.
To handle that heavy lifting efficiently, you can simplify your application by pushing compute down to the data layer. Ankit explains that if there are a lot of things you can get the database to do, then the applications become simpler. Instacart's core strategy was to move complex logic, such as filtering, ranking, and combining data through joins, out of the application layer and directly into their PostgreSQL database. This reduced network round trips and made use of the database's transactional capabilities. You can push complex filtering, joining, and ranking logic into your database to reduce application complexity, minimize network latency from multiple data fetching round trips, and improve overall system performance.
Moving all that logic into the database meant extending PostgreSQL to function as a full search engine. Instead of relying on a separate search system that could cause data synchronization issues, Instacart consolidated everything into a single, self-hosted cluster. They brought search indexes, ranking tables, availability data, and product taxonomies together in one place. For use cases that require both text search and complex, real-time transactional logic like inventory checks or personalized filtering, you can use a customized PostgreSQL setup to outperform a separate search system and enable single-query operations.
Keeping that consolidated cluster updated without interrupting shoppers required a bulk data ingestion and hot-swapping strategy. Rather than using a real-time streaming approach like Kafka, Ankit notes that all the writes were pipelined using S3, a cloud storage system, as the interface. Data was ingested in bulk from S3 into temporary tables, and the system used tools like pg_repack to build a new, optimized, and clustered primary table. That new table was then hot-swapped in, replacing the active table on the fly to serve live traffic with minimal disruption.
Making personalized ranking work directly inside the database relied heavily on PostgreSQL extensions, which are add-ons that give the database new capabilities. Before the pg_vector extension was available, Instacart built a custom C extension to run dot product calculations, a type of math used to score and rank items. This allowed them to handle personalized ranking models right inside the database.
Pushing complex logic into a customized PostgreSQL cluster can simplify your application and improve performance, though moving away from familiar tools like Elasticsearch can create a steep learning curve and impact team productivity. Eventually what we found out was that the DevEx, the developer experience, and how engineers use it, especially search engineers, it was less than ideal.