Import from object storage
Importing from object storage is the most efficient and cost-effective way to load large numbers of documents or records into an index. You store your data in object storage as JSON Lines (JSONL) files for a document index or Parquet files for a vector index. Then you integrate your object storage with Pinecone and start an asynchronous, long-running operation that imports and indexes your data. You can’t import into an index whose schema declaresembed or sparse_embed, so upsert in batches instead.
Upsert in batches
Upserting in batches is another efficient way to ingest large numbers of documents or records. A batch can hold up to 1,000 documents or records, or 96 when Pinecone embeds the text. See Upsert limits. Batch upserting is also a good option if you can’t work around bulk import’s limitations. For a document index, the Python SDK’sindex.documents.batch_upsert method splits a list of documents into batches and sends them in parallel. Failed batches are returned in the result instead of raised, so you can retry only the failures. For example, the following code upserts 1,000 documents into an index whose chunk_text field declares embed, then resends any batches a retry could help:
Python
Upsert and search in parallel
Pinecone is thread-safe, so you can send multiple upsert requests and multiple search requests in parallel to help increase throughput.Parallel queries
Python SDK v6.0.0 and later provideasync methods for use with asyncio. Asyncio support makes it possible to use Pinecone with async web frameworks such as FastAPI, Quart, and Sanic, and can make running queries in parallel much more efficient. For details, see Async requests.
You can also run synchronous queries in parallel with a thread pool. For example, the following code runs three text searches concurrently against a document index whose chunk_text field declares embed:
Python
index.query with query vectors instead, using the same client and thread pool:
Python
Python SDK options
Use gRPC
For a vector index, use the Python SDK with gRPC to run data operations such as upserts and queries over gRPC rather than HTTP for a modest performance improvement. The gRPC client doesn’t support the Documents API, so use the sync or async client for a document index.Upsert from a dataframe
To quickly ingest data into a vector index with the Python SDK, use theupsert_from_dataframe method. The method includes retry logic and batch_size, and performs especially well with Parquet datasets.