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.
Milvus 2.1 allows users to load a partition as multiple replicas to utilize the CPU and memory resources of extra query nodes. This feature boost the overall QPS and throughput with extra hardware. It is supported on PyMilvus in current release.
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.
In current release, all on-line query nodes will be divided into multiple replica groups according to the replica number specified by user. All replica groups shall have minimal memory resources to load one replica of the provided collection. Otherwise, an error will be returned.
from pymilvus import Collection
collection = Collection("book") # Get an existing collection.
collection.load(["novel"], replica_number=2)
# Or you can load a partition with the partition as an objectfrom pymilvus import Partition
partition = Partition("novel") # Get an existing partition.
partition.load(replica_number=2)
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.
Parameter
Description
collection_name
Name of the collection to load partitions from.
partition_names
List of names of the partitions to load.
replica_number (optional)
Number of the replica to load.
Get replica information
You can check the information of the loaded replicas.
from pymilvus import Partition
partition = Partition("novel") # Get an existing partition.
partition.load(replica_number=2) # Load partition as 2 replicas
result = partition.get_replicas()
print(result)
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.