id: load_partition.md
related_key: load partition
summary: Learn how to load a partition into memory for search or query in Milvus.
Load a Partition
This topic describes how to load a partition to memory. Loading partitions instead of the whole collection to memory can significantly reduce the memory usage. All search and query operations within Milvus are executed in memory.
In current release, volume of the data to load must be under 90% of the total memory resources of all query nodes to reserve memory resources for execution engine.
{{fragments/multiple_code.md}}
from pymilvus import Collection
collection = Collection("book") # Get an existing collection.
collection.load(["novel"])
# Or you can load a partition with the partition as an object
from pymilvus import Partition
partition = Partition("novel") # Get an existing partition.
partition.load()
await milvusClient.partitionManager.loadPartitions({
collection_name: "book",
partition_names: ["novel"],
});
err := milvusClient.LoadPartitions(
context.Background(), // ctx
"book", // CollectionName
[]string{"novel"}, // partitionNames
false // async
)
if err != nil {
log.Fatal("failed to load partitions:", err.Error())
}
milvusClient.loadPartitions(
LoadPartitionsParam.newBuilder()
.withCollectionName("book")
.withPartitionNames(["novel"])
.build());
load -c book -p novel
Parameter |
Description |
partition_name |
Name of the partition. |
Parameter |
Description |
collection_name |
Name of the collection to load partitions from. |
partition_names |
List of names of the partitions to load. |
Parameter |
Description |
ctx |
Context to control API invocation process. |
CollectionName |
Name of the collection to load partitions from. |
partitionNames |
List of names of the partitions to load. |
async |
Switch to control sync/async behavior. The deadline of context is not applied in sync load. |
Parameter |
Description |
CollectionName |
Name of the collection to load partitions from. |
PartitionNames |
List of names of the partitions to load. |
Option |
Description |
-c |
Name of the collection to load partitions from. |
-p (Multiple) |
The name of the partition to load. |
Constraints
- Error will be returned at the attempt to load partition(s) when the parent collection is already loaded. Future releases will support releasing partitions from a loaded collection, and (if needed) then loading some other partition(s).
- “Load successfully” will be returned at the attempt to load the collection that is already loaded.
- Error will be returned at the attempt to load the collection when the child partition(s) is/are already loaded. Future releases will support loading the collection when some of its partitions are already loaded.
- Loading different partitions in a same collection via separate RPCs is not allowed.
What’s next
- Learn more basic operations of Milvus:
- Explore API references for Milvus SDKs: