Velamuvi AIAcademy

Lesson 9 of 9 · Tools

Choosing a Vector Database

Choose a vector database: scale, existing stack, filtering, hybrid search, hosting and cost, and how Chroma, pgvector, Pinecone and Qdrant compare.

  • 7 min read
  • Intermediate
  • Reviewed
In this lesson you will learn
  • Ask the questions that decide which vector database fits a project
  • Compare the main options and their typical uses
  • Estimate how much memory a collection needs
  • Design your app so you can switch databases later

There is no single best vector database

Every option in this course can store vectors and find near neighbours. The right choice depends on your situation, and for most projects several options would work. Start with these questions:

  1. How many vectors, now and in a year? Thousands, millions or billions?
  2. What do you already run? A team that already operates PostgreSQL has a head start with pgvector.
  3. Who will run it? Do you want a managed service, or do you have people to run servers?
  4. Where must the data live? Some customers and laws require data to stay in a region or on your own servers.
  5. What queries do you need? Heavy metadata filtering, multi-tenancy, hybrid keyword search?
  6. How fast, and how many at once? A chatbot with a few users is very different from a search box with thousands of searches a second.
  7. What will it cost? Managed services charge for storage and queries; self-hosting costs servers and people's time.

The main options

OptionWhat it isTypical fit
NumPy array or Python listExact search in your own codeUp to tens of thousands of vectors that rarely change
FAISSA library of fast indexes (not a database)Research, batch jobs, building your own service
ChromaOpen source; embedded or serverLearning, prototypes, small to medium apps
pgvectorExtension for PostgreSQLApps already on PostgreSQL; vectors next to business data
PineconeFully managed serviceTeams that want no servers to run
QdrantOpen source, plus a managed cloudStrong filtering, self-hosting, data-location rules
Weaviate, MilvusOpen source, plus managed cloudsLarge-scale and feature-rich deployments
Elasticsearch, OpenSearchSearch engines with vector fieldsTeams with existing keyword search who want hybrid search

Estimate the memory

Fast vector search keeps the vectors (and the index) in memory, so size is often the deciding factor. Each number takes 4 bytes as a float32, 2 bytes as a float16, or 1 byte with 8-bit quantization:

Try it yourselfPython
# Rough memory needed to keep vectors (plus an HNSW graph) in RAM.
def estimate_gb(n_vectors, dims, bytes_per_number=4, links_per_vector=32):
    vectors = n_vectors * dims * bytes_per_number
    graph = n_vectors * links_per_vector * 4          # each link is a 4-byte id
    return (vectors + graph) / 1e9

print(f"{'Vectors':>11} {'Dims':>5} " + " ".join(f"{h:>9}" for h in ["float32", "float16", "int8"]))
for n, dims in [(100_000, 768), (1_000_000, 1536), (10_000_000, 1536), (100_000_000, 1024)]:
    sizes = [estimate_gb(n, dims, b) for b in (4, 2, 1)]
    print(f"{n:>11,} {dims:>5} " + " ".join(f"{s:>7.1f}GB" for s in sizes))

A million 1,536-number vectors fit comfortably on one server. A hundred million need a cluster, quantization, or a disk-based index, which is where dedicated databases and managed services earn their keep. Smaller embeddings help too: many modern models offer shorter vectors at a small cost in quality.

Keep switching easy

Your first choice does not have to be forever, if you plan for it:

  • Keep your source data. Store the original text, metadata and chunk IDs in your own storage (files or a normal database). The vector database should be rebuildable from it.
  • Record the embedding model with every collection. Switching models means re-embedding everything anyway.
  • Hide the database behind a small module with functions such as upsert_chunks(...) and search(query_vector, filters, k). The rest of the app never calls the vector database directly, so changing it touches one file.
  • Keep a test set of real queries with known good results, so you can check recall and quality before and after a switch.

Common mistakes

Practice exercise

Before choosing a server, estimate whether 3 million 1,024-number embeddings fit in its memory.

Your solutionPython
n_vectors = 3_000_000
dims = 1024
bytes_per_number = 4          # float32
server_ram_gb = 16

# Work out the memory for the vectors alone (in GB, where 1 GB = 1e9 bytes)
# and print:
# Vector memory: 12.3 GB
# Fits in 16 GB: yes      (or no)
Knowledge check

Your app already uses PostgreSQL and needs vector search over 300,000 product descriptions, filtered by price and stock. Which option is usually the simplest good fit?

Summary

  • Choose by scale, existing stack, operations, data location, query needs, speed and cost.
  • Chroma for learning and prototypes, pgvector alongside PostgreSQL, dedicated databases (Pinecone, Qdrant, Weaviate, Milvus) for large or demanding workloads.
  • Memory is roughly vectors × dimensions × bytes per number, plus the index.
  • Keep the source data, record the embedding model, wrap the database in one module, and keep a test set, so switching stays easy.

Course complete

You can now explain how vector databases store and search embeddings, how HNSW and IVF indexes trade accuracy for speed, how filtering and hybrid search work, and how to use Chroma, pgvector, Pinecone and Qdrant. Next: put it all to work in Retrieval-Augmented Generation, where a vector database feeds an LLM the knowledge it needs to answer.

Finished reading? Tick it off to track your progress.