Start With What You Already Run
For a smaller corpus, pgvector in the Postgres you already run is often cheaper and simpler. A managed vector service earns its place when the scale, or the work of operating an index, is more than you want to take on.
You want vector search at scale without becoming the team that tunes index shards and plans capacity. A managed service is the obvious answer, and the first design is usually one shared index with a tenant field. It works until one endpoint forgets the filter and shows one customer’s content to another.
Pinecone’s serverless model charges for storage, reads and writes instead of always-on capacity, which suits spiky workloads. Getting value from it is mostly about structure: namespaces for isolation, ids you can update and delete, and your own database kept as the source of truth. Below is how to set it up so the safe path is the only path.
- You're running pgvector and your index rebuilds take hours
- You don't know whether to use one index with namespaces or many indexes
- You're paying for pods that sit idle 80% of the day
- Your hybrid search is two queries glued together in app code
Indexes, Namespaces and Metadata
A Pinecone index is a logical collection with a fixed dimension and metric. Inside it, namespacespartition vectors — searches are scoped to a single namespace, which makes them the right unit for multi-tenant isolation. Each vector carries an id, the numeric values, and an optional metadata object (used for filtering at query time).
- Serverless indexes — pay for storage + read/write units, scale to zero, regional (AWS, Azure, GCP).
- Pod-based indexes — predictable latency, always-on, more expensive. Legacy default.
- Sparse-dense (hybrid) — combine BM25-style sparse vectors with dense embeddings in one query.
- Reranking — call a built-in reranker (Cohere, BGE) on top-k candidates without extra infra.
flowchart LR
APP["App"] --> NS1["Namespace<br/>tenant-42"]
APP --> NS2["Namespace<br/>tenant-7"]
APP --> NSN["Namespace<br/>tenant-N"]
NS1 --> IDX["Serverless Index<br/>(dim=1536, cosine)"]
NS2 --> IDX
NSN --> IDX
IDX --> S3["Object storage<br/>(scale to zero)"]
style IDX fill:#0078D4,color:#fff,stroke:#005a9e
style S3 fill:#16a34a,color:#fff,stroke:#15803d
Building Multi-Tenant Search
Step 1: Create a serverless index
// dotnet add package Pinecone.Client
using Pinecone;
var pc = new PineconeClient(Environment.GetEnvironmentVariable("PINECONE_API_KEY")!);
await pc.CreateIndexAsync(new CreateIndexRequest
{
Name = "rag-prod",
Dimension = 1536,
Metric = MetricType.Cosine, // hybrid in one index needs MetricType.Dotproduct (Step 4)
Spec = new ServerlessIndexSpec
{
Serverless = new ServerlessSpec
{
Cloud = ServerlessSpecCloud.Aws,
Region = "us-east-1"
}
}
});Step 2: Upsert in batches with namespaces
var index = pc.Index("rag-prod");
// Batch up to 100-1000 per request; keep total payload < 2 MB
var batch = chunks.Select(c => new Vector
{
Id = c.Id,
Values = c.Embedding, // float[]
Metadata = new Metadata
{
["doc_id"] = c.DocId,
["title"] = c.Title,
["category"] = c.Category
}
}).ToList();
await index.UpsertAsync(new UpsertRequest
{
Vectors = batch,
Namespace = $"tenant-{tenantId}" // ← isolation boundary
});Check it: Upsert a record and query for it at once. It may not be there yet, because the index is eventually consistent. Your tests should wait or retry, not assume.
Step 3: Query with metadata filter
var resp = await index.QueryAsync(new QueryRequest
{
Namespace = $"tenant-{tenantId}",
Vector = queryEmbedding,
TopK = 10,
IncludeMetadata = true,
Filter = new Metadata
{
["category"] = new Metadata { ["$in"] = new[] { "docs", "blog" } }
}
});
foreach (var m in resp.Matches)
Console.WriteLine($"{m.Score:F3} {m.Metadata?["title"]}");Check it: Query as one tenant for a phrase that only another tenant's articles contain. You should get nothing back.
Step 4: Hybrid (sparse + dense) for keyword + semantic
// Sparse-dense queries only work on a dotproduct index; others return an error.
// Build sparse vector with BM25 / SPLADE / pinecone-text
var sparse = new SparseValues
{
Indices = sparseIndices, // uint[]
Values = sparseWeights // float[]
};
var hybrid = await index.QueryAsync(new QueryRequest
{
Namespace = $"tenant-{tenantId}",
Vector = denseEmbedding,
SparseVector = sparse,
TopK = 20,
IncludeMetadata = true
});Check it: Search for an exact identifier from your own content. With sparse vectors in place, it should rank first.
Step 5: Rerank top-k with the built-in reranker
var reranked = await pc.Inference.RerankAsync(new RerankRequest
{
Model = "bge-reranker-v2-m3",
Query = userQuery,
Documents = hybrid.Matches
.Select(m => new Dictionary<string, object?> { ["text"] = m.Metadata!["title"]?.Value })
.ToList(),
TopN = 5,
ReturnDocuments = true
});Check it: Run twenty real queries with the reranker and without it, and count how often the known right answer is in the top five.
Step 6: Delete-by-namespace for tenant offboarding
// One call removes every record in the tenant's namespace
await index.DeleteAsync(new DeleteRequest
{
DeleteAll = true,
Namespace = $"tenant-{tenantId}"
});Check it: Delete a test tenant's namespace, then query it. Nothing should come back, and other tenants should be untouched.
Mistakes That Leak or Drift
- One namespace per index. Plans cap indexes far lower than namespaces. Use namespaces inside a shared index for tenants; reserve separate indexes for separate dimensions or metrics.
- No metadata limit awareness. Per-record metadata is size-limited. Storing the full document text inflates writes and reads — keep an ID and look the body up elsewhere.
- Tiny upsert batches. One vector per request burns write units and latency. Batch 100-1000 per call.
- Querying without a namespace. The default namespace becomes a shared landfill across tenants — privacy bug waiting to happen. Always pass
Namespace. - Sparse vectors as an afterthought. For factual / keyword queries, hybrid can improve relevance a lot. Build sparse at ingest time, not at query time.
- Forgetting eventual consistency. Pinecone is eventually consistent, so upserts can take a moment to show up. Don't write-then-immediately-read in tests.
Try It on Your Own System This Week
Three checks on a Pinecone index you already use, about an hour in total:
- Search your code for queries with no namespace. Each one reads from a space shared by everyone.
- Look at the size of one record's metadata. If the document body is in there, move it out and keep an ID.
- Check your upsert batch size. One vector per request costs more and runs slower than a few hundred at a time.
How I Would Set It Up
- Default to a single serverless index with namespace-per-tenant.
- Keep metadata small (IDs and filters), not the document body.
- Batch upserts; the SDK is happy with hundreds per request.
- Use hybrid (sparse + dense) for any query mix that includes keywords.
- Rerank top-20 down to top-5 — built-in rerankers add a little latency and can improve relevance.
DeleteAll = truewith a namespace is your tenant-offboarding primitive.- For smaller corpora, pgvector is often cheaper. Pick Pinecone when scale or operational simplicity wins.
Costs and Migrations
Pinecone's serverless pricing charges for storage, writes and reads, so your bill depends on how you use it, and small design choices move it a lot. Using fewer dimensions cuts storage. Requesting include_metadata and large top_k values raises read cost. Writing the same vectors repeatedly costs money too, so deduplicate before upserting, and hash your content so that you only re-embed what changed.
Namespaces are the best tool you have here. Put each tenant in its own namespace, and queries only touch that tenant's data. That's faster, usually cheaper, and far safer than a metadata filter, where one missing clause leaks another customer's documents. Deleting a tenant also becomes a single operation, which helps with GDPR requests.
Recall needs measuring
Vector databases don't tell you when results get worse. Keep a test set of queries with known relevant documents, and track recall@10. Run it after you change the embedding model, the chunking or the metadata schema. If you change embedding models, you must re-embed the whole corpus into a new index, because vectors from different models can't be mixed. Build the new index alongside the old one, compare recall, then switch reads with a flag. Keep the old one until you're sure.
Hybrid search and reranking
Dense vectors alone miss exact terms such as SKUs and error codes. Pinecone supports sparse-dense retrieval, and adding a keyword signal is usually the cheapest improvement you can make. A reranker on the top 50 results improves precision further, at the cost of a little latency.
Should you use it?
Pinecone's main benefit is that it takes operations off your plate, and that can be worth paying for. If you already run Postgres and have fewer than a few million vectors, pgvector is usually simpler. Keep your embeddings and source documents in your own storage regardless. That way the vector store is a rebuildable index rather than your system of record, and you can leave if the pricing or your needs change. Store the embedding model name with each record too, so you always know what produced a vector.
Metadata Design
Decide your metadata up front, because it drives filtering. Store only what you filter on or need to show, and keep values simple. Put the full text in your own store, and fetch it by ID, because metadata has size limits and adds to read costs. Include a document version, so that you can find and remove stale chunks when a source changes. Delete by ID prefix or filter when a document is removed, otherwise old text will keep turning up in answers.