Arc Labs
BrainDocsPricing
GitHubSign inGet Started
LearnComparisons

Brain vs PostgreSQL + pgvector

By Arc Labs Research·May 12, 2026·7 min read
TL;DR

pgvector adds vector search to PostgreSQL. Brain is a purpose-built agent memory layer. pgvector is good for structured data with vector similarity; Brain is good for agent context, conversation history, and multi-turn reasoning. pgvector requires SQL ops; Brain is purpose-built for agents.

Overview

pgvector is a PostgreSQL extension that adds vector search to relational tables. Brain is a memory layer designed for agent loops. The comparison is about database choice vs. memory architecture.

pgvector lets you store embeddings in PostgreSQL and query them with similarity functions. It's SQL-native and works well for structured data (documents, products, users) that also need vector search.

Brain is built specifically for agent memory: storing context, decisions, and outcomes in a format optimized for agent loops. Brain is not built on Postgres — it runs its own purpose-built Rust engine (a memory-mapped vector arena, in-RAM HNSW, a redb B-tree for metadata, and a tantivy BM25 index) and abstracts the schema and retrieval logic for agents.

Feature comparison

FeaturepgvectorBrain
PurposeVector search in PostgresAgent memory layer
Data modelRelational + vectorsStructured agent context
Retrieval interfaceSQL (similarity_search)Agent SDK (recall)
Latency50–500ms (depends on query)Sub-50ms (optimized for agent loops)
Schema managementManual (CREATE TABLE, migrations)Automatic (agent-aware defaults)
FilteringFull SQL (WHERE, JOIN)Scoped to agent context
Transaction supportACID transactionsCausal consistency per agent
DeploymentManaged Postgres instanceSelf-hosted or managed Cloud
Learning curveSQL knowledge requiredAgent SDK only

When to use pgvector

  • Your primary data is relational (users, products, orders)
  • You want to add vector similarity to an existing Postgres database
  • You need complex filtering with WHERE clauses and JOINs
  • You have DBA infrastructure to manage Postgres at scale
  • Your vectors are secondary to structured queries

Example: E-commerce platform with products table that needs similar-product search.

SELECT * FROM products
WHERE embedding <-> query_embedding < 2
ORDER BY embedding <-> query_embedding
LIMIT 10;

When to use Brain

  • You're building agent memory (conversation history, decisions)
  • You need sub-50ms retrieval to keep agent loop latency low
  • You want semantic search + keyword matching (hybrid)
  • You prefer SDKs to SQL
  • You need agent-specific primitives (retrieve, decide, reflect)

Example: Multi-turn agent that needs to remember past conversation context.

import { BrainClient, RecallBuilder } from "@brain-db/sdk";

const auth = { kind: "token", token: new TextEncoder().encode(process.env.BRAIN_API_KEY!) };
const memory = await BrainClient.connect("127.0.0.1", 9090, { auth });
const answer = await memory.recall(
  new RecallBuilder("What did the user ask about pricing?").maxResults(5).build(),
);

Integration patterns

pgvector + Brain: Use pgvector for a document corpus, Brain for agent memory. Agent queries pgvector for documents, then uses Brain to track which documents informed which decisions. (Brain persists to its own engine — vector arena, WAL, redb, HNSW — so it doesn't depend on your Postgres instance.)

import { EncodeBuilder } from "@brain-db/sdk"; // memory is a connected BrainClient

// Document search (pgvector)
const docs = await postgres.query(
  `SELECT * FROM documents
   WHERE embedding <-> $1 < 2
   LIMIT 5`,
  [queryEmbedding]
);

// Agent memory (Brain)
await memory.encode(new EncodeBuilder(JSON.stringify(docs)).build());

Operational overhead

pgvector: Requires Postgres ops (backups, scaling, index tuning). Index maintenance grows with vector count. Good if you already run Postgres.

Brain: Managed Cloud handles ops. Embedding deployment is stateless and scales independently.

Pricing & scaling

pgvector: Postgres hosting (RDS, Managed Postgres, self-hosted). Index size grows with vectors; typically 8 bytes per dimension per vector. For 1M vectors at 1536 dimensions: ~12 GB of storage.

Brain: Pay per vector stored + queries. Typically $0.001 per 1K vectors/month for Cloud.

At <10M vectors, Brain is cheaper. At very large scales (100M+ vectors), pgvector's per-MB hosting cost may be lower, but operational complexity increases.

Summary

  • pgvector: If you own Postgres and need vector search on relational data.
  • Brain: If you're building agent memory and want to avoid SQL infrastructure.

Many teams use both: pgvector for documents, Brain for agent context.

Related reading

  • ComparisonsBrain vs Redis Vector
  • ComparisonsAlternatives to Mem0
  • ComparisonsBrain vs. Vector Databases
PreviousBrain vs PineconeNextBrain vs Redis Vector

Updates from the lab.

Engineering notes, research drops, occasional product updates. Roughly monthly.

Arc Labs

Cognitive infrastructure for AI agents. Open core in Rust. Composable primitives you own.

GitHubX / TwitterDiscussions

Brain

  • Memory Layer
  • Documentation
  • Pricing
  • Changelog
  • Status

Developers

  • Start here
  • TypeScript SDK
  • Python SDK
  • Rust SDK
  • MCP Server

Company

  • About
  • Careers
  • Blog
  • Security
  • Contact
Encode"Priya lives in Berlin."mem_7f3a · storedRecall"where does Priya live?"→ BerlinSupersede"Priya moved to Lisbon."mem_9c21 ⊃ mem_7f3aBerlin→ LisbonARC LABSARC LABSARC LABS
© 2026 ARC LABS · BANGALOREPrivacyTermsDPAApache 2.0