Skip to main content
Use Neon as a vector store in Mem0, powered by PostgreSQL and the pgvector extension. Neon is a serverless Postgres platform. Since Mem0 supports Postgres through the pgvector provider, Neon can be used with a standard Postgres connection string.

Usage

SQL Migration

You don’t need to run any SQL migrations. Mem0 creates the collection table when it initializes the pgvector store.

Environment

Config

Indexing

The pgvector provider can create an HNSW index for faster vector search.
  • Set hnsw to true to enable a Hierarchical Navigable Small World index.
  • Leave hnsw as false if you want to create or manage indexes yourself.
The pgvector provider uses cosine similarity for vector search. Make sure your embedding dimensions match the configured embedding_model_dims value.

Best Practices

  1. Index Selection:
    • Use hnsw for faster search performance when memory usage is not a constraint
    • Manage indexes manually if you need a different pgvector index strategy
  2. Connection String:
    • Always use environment variables or even better, a secret manager for sensitive information in the connection string
    • Format: postgresql://user:password@host:port/database