SteelReed

Search

Search posts, questions…

AI & LLMQuestion 2 / 25

Junior

What is RAG, and when is pgvector enough instead of a separate vector database?

Short answer

RAG finds the document chunks closest to the question and puts them in the prompt, so the LLM answers from your documents and can cite sources. pgvector is enough when the source data already lives in PostgreSQL and you're at a few million vectors.

chunk + embedembedk allowed chunksDocumentspgvector, with permissionsQuestionPrompt + chunksLLM answerswith sources

3 points to say:

  1. Two paths: ingest (chunks of 200–800 tokens, 10–20% overlap, stored with permissions) and query (embed the question, fetch k allowed chunks).
  2. pgvector's big win is one transaction, one backup, joins with permission tables; a separate vector DB at hundreds of millions of vectors or when search load slows the main workload.
  3. Operators: <=> cosine, <-> L2, <#> negative inner product; quick estimate: 3 million 1,536-dim vectors ≈ 18 GB.

Keep reading the deep dive

Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.