---
title: "Search From a Million Books in Milliseconds With Neon and pg_search"
description: "Swapping the OpenAI-embedding semantic search in Vercel's Next.js Book Inventory template for pg_search's BM25 full-text index on Neon Postgres made title searches over a million Goodreads books roughly 180–236x faster, dropping from about 2.7 seconds to 11–14 ms. The setup loads the dataset into a books table, prewarms the table and index with pg_prewarm, creates a covering bm25 index, and queries with the @@@ operator and paradedb.match in conjunction_mode."
url: "https://swe.quest/articles/search-from-a-million-books-in-milliseconds-with-neon-and-pg-search-2b2bd7a3bf8b0ad8"
canonical: "https://neon.com/blog/search-in-milliseconds-pgsearch"
source: "Neon"
published: "2025-03-26"
difficulty: "medium"
kind: "Case study"
reading_minutes: 6
tags: ["postgres","search","performance"]
---

# Search From a Million Books in Milliseconds With Neon and pg\_search

A post on [Neon](https://swe.quest/sources/neon.md), published 2025-03-26, 6 min read, Case study. Original: [https://neon.com/blog/search-in-milliseconds-pgsearch](https://neon.com/blog/search-in-milliseconds-pgsearch)

## Summary

Swapping the OpenAI-embedding semantic search in Vercel's Next.js Book Inventory template for pg\_search's BM25 full-text index on Neon Postgres made title searches over a million Goodreads books roughly 180–236x faster, dropping from about 2.7 seconds to 11–14 ms. The setup loads the dataset into a books table, prewarms the table and index with pg\_prewarm, creates a covering bm25 index, and queries with the @@@ operator and paradedb.match in conjunction\_mode. On the app side, Drizzle is replaced by Neon's HTTP serverless driver, and Vercel functions are co-located in us-east-2 with the database. Side-by-side tsvector/tsquery and pg\_search queries with timings are included for reproduction.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Search](https://swe.quest/tags/search.md) (Backend & APIs)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)

## Prerequisites

- PostgreSQL full-text search ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- SQL query plans ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- Postgres extensions ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))

## Keywords

pg\_search, Neon, ParadeDB, BM25, pg\_prewarm, Next.js, Vercel, tsvector

## Related posts

- [pg\_search is Available on Neon](https://swe.quest/articles/pg-search-is-available-on-neon-98d919ff82afb749.md): Neon · 2025-03-18 · Medium · 8 min read · PostgreSQL, Search, Performance engineering
  ParadeDB's pg\_search extension, now available on Neon in AWS regions, adds a Tantivy-powered BM25 inverted index to Postgres, bringing relevance ranking, fuzzy matching, faceting, highlighting and JSON-aware search that native tsvector/GIN full-text search lacks.
- [Build Your Own Full-Text Search CMS with Neon and pg\_search](https://swe.quest/articles/build-your-own-full-text-search-cms-with-neon-and-pg-search-d1362b037df7a369.md): Neon · 2025-07-07 · Medium · 12 min read · Search, PostgreSQL, TypeScript
  A minimal CMS built on Postgres with Next.js, Prisma and Zod, using the pg\_search extension's BM25 index for full-text search instead of a hosted CMS.
- [Semantic search using OpenAI, pg\_embedding and Neon](https://swe.quest/articles/semantic-search-using-openai-pg-embedding-and-neon-aeafbc27d93ca728.md): Neon · 2023-08-25 · Medium · 9 min read · Vector search, PostgreSQL, LLMs, Serverless, TypeScript
  A YC idea-matcher app implements semantic search by embedding ~4,400 YCombinator company descriptions with OpenAI's text-embedding-ada-002 (1536 dimensions) and storing them as real\[\] columns in Neon Postgres via the pg\_embedding extension.
- [Neon Docs search is now built on Neon](https://swe.quest/articles/neon-docs-search-is-now-built-on-neon-6358bcc8a0cf6214.md): Neon · 2026-10-26 · Medium · 6 min read · Search, PostgreSQL, Vector search, Caching, AI agents
  Neon's docs search now runs entirely on its own stack: Lakebase Postgres with the lakebase\_vector (pgvector-compatible ANN) and lakebase\_text (BM25) extensions, a Hono API on Neon Functions, and Neon AI Gateway for embeddings and reranking.
- [CommSync Runs Text, Vector, and Hybrid Search on Postgres with Lakebase Search](https://swe.quest/articles/commsync-runs-text-vector-and-hybrid-search-on-postgres-with-lakebase-search-8b687b59899ef5ac.md): Neon · 2026-07-30 · Medium · 5 min read · Search, PostgreSQL, Vector search, RAG & retrieval
  CommSync, a unified SMS/email inbox, runs keyword, semantic and hybrid search entirely in Postgres using Neon's Lakebase Search extensions. lakebase\_text provides BM25 search with top-K pushdown over tsvector, and lakebase\_vector is a pgvector-compatible drop-in with an ANN index.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
