Optimizing Index Performance
1. Selecting Appropriate Pod Type
| Workload | Pod Type |
|---|---|
| Large index, low QPS | s1 |
| Balanced | p1 |
| High QPS / low latency | p2 |
2. Configuring Pod Size
| Symptom | Action |
|---|---|
High index_fullness | Upgrade pod size or add shards |
| Slow queries with selective filter | Upgrade size; more memory |
| High write latency | Larger size or more shards |
3. Setting Optimal Replica Count
Example: Estimate Replicas
# target 1500 QPS on p1.x1 (~100 QPS each)
required_replicas = math.ceil(1500 / 100) # 15
pc.configure_index("docs", replicas=15)
| Rule | Detail |
|---|---|
| Linear QPS scaling | Replicas ~= target_QPS / single_pod_QPS |
| Cost linear | Replicas multiply pod cost |
4. Tuning Batch Sizes
| Op | Recommended Batch |
|---|---|
| Upsert @ 1536d | 100 |
| Fetch | 1000 IDs |
| Delete by ID | 1000 |
5. Implementing Connection Pooling
| Client | Mechanism |
|---|---|
| Python REST | pool_threads param |
| Python gRPC | Single channel, reuse |
| Node.js | Underlying fetch keep-alive |
6. Using Async Operations
Example: Async Upsert
from pinecone import PineconeAsyncio
import asyncio
async def upsert_all(batches):
async with PineconeAsyncio(api_key="...") as pc:
async with pc.IndexAsyncio(name="docs") as idx:
await asyncio.gather(*(idx.upsert(vectors=b) for b in batches))
7. Optimizing Metadata Filtering
| Tip | Effect |
|---|---|
| Pre-bucket numbers | Lower cardinality = faster |
| Selective indexing (pod) | Skip non-filtered fields |
| Avoid wide $in | Slow on 1000+ values |
8. Caching Query Results
Example: Redis Cache
import hashlib, json, redis
r = redis.Redis()
def cached_query(qv, top_k, ns):
key = "q:" + hashlib.sha256(
json.dumps([qv, top_k, ns]).encode()).hexdigest()
if (v := r.get(key)): return json.loads(v)
res = index.query(vector=qv, top_k=top_k, namespace=ns)
r.set(key, json.dumps(res), ex=300)
return res
9. Monitoring Query Latency
| Source | Metric |
|---|---|
| Pinecone console | p50/p95/p99 latency |
| Client-side | Wrap calls with timer |
| APM (Datadog, NewRelic) | End-to-end latency |
10. Reducing Vector Dimensions
| Method | Tradeoff |
|---|---|
| Matryoshka (truncate) | Small accuracy loss |
| PCA | Larger loss; needs training |
| Quantization (int8) | 4× storage savings |
11. Understanding Throughput Limits
| Index Type | Throughput |
|---|---|
| p1.x1 | ~100 QPS |
| p2.x1 | ~200 QPS |
| Serverless | Scales with traffic, plan-dependent RU/s |