Performance: Pinecone cloud vector store
This concept affects the speed of vector search queries and the responsiveness of applications using Pinecone for similarity search.
async function searchVectorsBatch(queryVectors) { const results = await pinecone.query({ queries: queryVectors, topK: 10 }); return results; }
async function searchVectors(queryVectors) { for (const vector of queryVectors) { await pinecone.query({ vector: vector, topK: 10 }); } }
| Pattern | Network Calls | Backend Load | Latency | Verdict |
|---|---|---|---|---|
| Sequential single queries | Multiple calls (N calls for N vectors) | High (each query processed separately) | High (sum of all calls) | [X] Bad |
| Batch vector queries | Single call | Optimized (batch processed) | Low (one combined call) | [OK] Good |
import pinecone
pinecone.init(api_key='key', environment='us-west1-gcp')
index = pinecone.Index('test-index')
result = index.query(vector=[0.1, 0.2, 0.3], top_k=1)
print(result.matches)import pinecone
pinecone.init(api_key='key', environment='us-west1-gcp')
index = pinecone.Index('my-index')
index.upsert(vectors=[["id1", [0.1, 0.2, 0.3]]])Pass the test and this pattern moves unknown