Cortex Memory vs. Custom RAG
Managed memory such as Cortex Memory and a custom RAG store answer the same need with different owners. Choose by who must control access filters, freshness and deletion.
5 min read / Updated / Last checked
- Format
- Comparison · Advanced
- Who it is for
- Builders and technical founders
- You leave with
- Decide when managed durable memory makes sense, and score any retrieval backend on hits, leaks and stale answers before you commit.
The problem
In September 2024, Anthropic published measurements of a common failure in retrieval-augmented generation (RAG), the pattern where an application searches its own documents and hands the best passages to a model. With standard embeddings, the failure rate for retrieving the right passages within the top 20 results was 5.7%. Adding a short, chunk-specific explanation to every chunk before indexing it for both embedding and BM25 keyword search, then reranking the results, brought that down to 1.9% [6].
Two things follow. Retrieval quality is a tunable engineering result, not a property of a vendor. And every tuning step (chunking, embedding, ranking, filtering) is a decision someone has to own.
That is the real choice behind "Cortex Memory or custom RAG." A managed memory backend takes many of those decisions for you. A custom store leaves them all with your team. The name adds confusion: Cortex Memory is a memory backend for agents, while Snowflake's Cortex Search is a managed search service over warehouse data. Neither is a standard, and they do not share an API. A founder needs to know which jobs move to the vendor, which stay in-house whatever the vendor says, and how to test the result.
How it works
Custom RAG is a pipeline your team builds: split documents into chunks, turn each chunk into an embedding (a list of numbers that places similar text close together), store the vectors with metadata, then at question time filter, search and rank. With Postgres and the pgvector extension, vectors live next to ordinary columns such as tenant and audience. One detail matters for access control: with approximate indexes, pgvector applies filters after scanning the index, so a strict filter can return too few rows. Its documentation recommends iterative index scans or filter indexes for that case [3].
Cortex Memory moves the pipeline into a backend that runs on Convex. As documented in November 2026, the backend "owns extraction, fact resolution, summaries, chunking, embedding and optional graph projection," deriving memory from the conversation transcript and other eligible sources. Each derived fact, chunk and vector keeps tenant or space, source revision and hash provenance, and an edit or deletion invalidates stale derivations [4]. Memory indexing runs asynchronously, so a reply can be complete while memory status is still pending, and a strict mode fails or returns explicitly incomplete context instead of silently using stale memory [4]. Requests are scoped by a memory space, and caller-supplied tenant or user labels never grant access by themselves: access depends on verified tokens and grant checks [2]. The documentation covers an upcoming 0.39.0 release, with package publication listed as a separate step [1].
Snowflake Cortex Search is a third shape: a managed hybrid search service (vector plus keyword search, then semantic reranking) defined in SQL over a table, refreshed on a target lag, and queried with the owner's rights [5]. It fits teams whose documents already live in Snowflake.
Who does each retrieval job
Fig. 01| Dimension | Custom RAG | Cortex Memory | Cortex Search |
|---|---|---|---|
| Extract facts | Your code | Backend, async | None: rows as written |
| Freshness | Your reindex job | Status and watermarks | Target lag refresh |
| Access check | Your WHERE clause | Tokens and grants | Owner rights, filters |
| Deletion | DELETE, reindex | Invalidates derivations | Change base table |
| Data lives in | Your Postgres | Convex | Snowflake |
By the numbers
- top-20 retrieval failure rate before and after contextual retrieval with reranking, in Anthropic's tests [6]
- 5.7% to 1.9%
- default queries per second per Cortex Search service, 140 per account [5]
- 20
- rows: above this, creating a Cortex Search service fails [5]
- 400M
- dimensions: the largest vector pgvector can index, 4,000 with half precision [3]
- 2,000
- memories and facts Cortex Memory puts into context by default [2]
- 4 + 4
| Item | Custom RAG on pgvector | Cortex Memory | Snowflake Cortex Search |
|---|---|---|---|
| Search method | Exact, HNSW or IVFFlat indexes [3] | Chunks and vectors per embedding profile [2] | Vector plus keyword, then reranking [5] |
| Default embedding | Your choice | Profile-specific vectors [4] | snowflake-arctic-embed-m-v1.5, 768 dimensions [5] |
| Freshness signal | Whatever you build | Per-stage watermarks and memory status [4] | Target lag on refresh [5] |
| Release state | pgvector 0.8.7, Postgres 13 or later [3] | Docs for upcoming 0.39.0, packages pending [1] | Available in many AWS, Azure and Google Cloud regions [5] |
| Cost drivers | Your database and embedding calls | Not stated in the pages reviewed | Refresh compute, embedding tokens, serving per GB-month even when idle, storage [5] |
The Anthropic numbers come from the vendor's own tests on its chosen datasets [6]. What they show is the size of the lever: chunk preparation and reranking cut misses by about two thirds, so whoever owns those steps owns a large part of answer quality.
The table shows where control sits. With pgvector every limit is visible and every cost is your own infrastructure. Cortex Memory documents strong provenance and invalidation, but its packages were not yet published when its docs were reviewed, which is a real adoption risk for a product a customer depends on [1]. Cortex Search bills serving by indexed data size even when idle and caps throughput by default, which shapes cost and peak load [5].
Implementation
Start custom when documents are few, permissions are simple and the team knows Postgres. The schema below puts tenant, audience and version next to every vector, so access and freshness are enforced in the same query that ranks results. It ran as written on Postgres 17 with pgvector 0.8.7.
-- Custom RAG store: owner, audience and version sit next to every vector.
CREATE EXTENSION IF NOT EXISTS vector;
CREATE TABLE chunks (
id bigserial PRIMARY KEY,
tenant_id text NOT NULL,
audience text NOT NULL, -- 'customers', 'staff', ...
doc_id text NOT NULL,
doc_version integer NOT NULL,
is_current boolean NOT NULL DEFAULT true,
body text NOT NULL,
embedding vector(3) NOT NULL -- demo size; use your model's, e.g. 1536
);
CREATE INDEX ON chunks USING hnsw (embedding vector_cosine_ops);
CREATE INDEX ON chunks (tenant_id, audience) WHERE is_current;
INSERT INTO chunks (tenant_id, audience, doc_id, doc_version, is_current, body, embedding) VALUES
('acme', 'customers', 'refunds', 2, false, 'Refunds within 14 days.', '[0.9,0.1,0]'),
('acme', 'customers', 'refunds', 3, true, 'Refunds within 30 days.', '[0.9,0.1,0]'),
('acme', 'staff', 'refunds-internal', 1, true, 'Staff may override.', '[0.9,0.2,0]'),
('globex', 'customers', 'refunds', 1, true, 'No refunds on sale items.', '[0.9,0.1,0]');
-- Exact filters run with the vector search; iterative scans keep results from running dry.
SET hnsw.iterative_scan = strict_order;
SELECT doc_id, doc_version, body
FROM chunks
WHERE tenant_id = 'acme' AND audience = ANY (ARRAY['customers']) AND is_current
ORDER BY embedding <=> '[0.88,0.12,0]'
LIMIT 5;
-- Deletion is a statement you can run and verify, not a support ticket.
DELETE FROM chunks WHERE tenant_id = 'acme' AND doc_id = 'refunds' AND NOT is_current;The query returns only the current customer-facing refund chunk for tenant acme: never the staff note, never the old version, never another tenant's policy. In the application, the tenant and audience values come from the signed-in session, never from the model or the user's message. When a document changes, insert the new version and flip is_current on the old one in the same transaction, then delete old versions on a schedule.
Consider a managed backend such as Cortex Memory when the product needs memory extracted from conversations (facts about a user, not just document search), when several agents and interfaces must share one run, or when the team would otherwise build extraction, invalidation and status tracking itself [4]. Ask the vendor four questions in writing: where the data is stored, how a user is deleted from facts, chunks and vectors, what happens to answers while memory indexing is pending, and how to export everything.
Test it
Whatever you choose, run the same golden set through it before launch and after every change. The scorer below is backend-agnostic: it takes a search function, so it can wrap the SQL above or a vendor client.
"""Score any retrieval backend on the same golden set: managed memory or custom RAG."""
from dataclasses import dataclass
from typing import Callable
# search(question, tenant_id, groups) -> list of (doc_id, doc_version), best first
Search = Callable[[str, str, list], list]
@dataclass
class Case:
question: str
tenant_id: str
groups: list
expected: tuple # (doc_id, current version) that answers it
forbidden: tuple = () # doc_ids this caller must never see
def evaluate(search: Search, cases: list, k: int = 5) -> dict:
hits = leaks = stale = 0
for c in cases:
results = search(c.question, c.tenant_id, c.groups)[:k]
hits += c.expected in results
leaks += any(doc in c.forbidden for doc, _ in results)
stale += any(doc == c.expected[0] and ver < c.expected[1] for doc, ver in results)
n = len(cases)
return {"hit_rate": hits / n, "leaks": leaks, "stale": stale, "cases": n}
def passes(report: dict, min_hit_rate: float = 0.9) -> bool:
return report["leaks"] == 0 and report["stale"] == 0 and report["hit_rate"] >= min_hit_rate
if __name__ == "__main__":
golden = [
Case("How long do refunds take?", "acme", ["customers"], ("refunds", 3), ("refunds-internal",)),
Case("Can staff override a refund?", "acme", ["staff"], ("refunds-internal", 1)),
]
fake_index = {("acme", "customers"): [("refunds", 3)],
("acme", "staff"): [("refunds-internal", 1), ("refunds", 3)]}
def stub(question, tenant, groups):
return [r for g in groups for r in fake_index.get((tenant, g), [])]
report = evaluate(stub, golden)
print(report, "PASS" if passes(report) else "FAIL")Run python retrieval_eval.py. Expected with the stub: {'hit_rate': 1.0, 'leaks': 0, 'stale': 0, 'cases': 2} PASS. Replace the stub with a real backend and grow the golden set to at least 30 cases, a third of them access or version traps. Leaks and stale results must be zero. The hit rate threshold is yours to set. Then delete one test user and one test document, and confirm both disappear from search results, from any extracted facts, and from exports.
Decision
Choose by ownership, not by name.
- Custom RAG on Postgres: the default for a first product with documents in your own database. Cost is a database you already run plus embedding calls, and every access rule is a line of SQL you can test.
- Cortex Memory or a similar managed backend: worth a pilot when you need memory extracted from conversations and shared across agents, and only once its packages are published and deletion is demonstrated on your data [1][4].
- Snowflake Cortex Search: a fit when the documents already live in Snowflake and its throughput defaults and idle serving cost are acceptable [5].
- In every case, keep the golden-set test in CI. For how agents separate session, long-term and retrieval memory, see Agent Memory: Session, Long-Term and Retrieval.
Sources
- [1]Cortex Memory documentation (opens in a new tab)Cortex Memory, November 2026
- [2]SaintNick1214/Project-Cortex (opens in a new tab)GitHub, November 2026
- [3]pgvector (opens in a new tab)pgvector project on GitHub, November 2026
- [4]Memory orchestration (opens in a new tab)Cortex Memory documentation, November 2026
- [5]Cortex Search overview (opens in a new tab)Snowflake Documentation, November 2026
- [6]Contextual retrieval in AI systems (opens in a new tab)Anthropic, September 2024
Technical guidance, not legal or security certification.
Related resources
Need a technical review of an AI-built MVP?
Discuss your build