Skip to main content
Version: User Guides (Cloud)

Manage Partitions

A partition is a subset of a collection. Each partition shares the same data structure with its parent collection but contains only a subset of the data in the collection. This page helps you understand how to manage partitions.

Overview

When creating a collection, Zilliz Cloud also creates a partition named _default in the collection. If you are not going to add any other partitions, all entities inserted into the collection go into the default partition, and all searches and queries are also carried out within the default partition.

You can add more partitions and insert entities into them based on certain criteria. Then you can restrict your searches and queries within certain partitions, improving search performance.

A collection can have a maximum of 1,024 partitions.

📘Notes

The Partition Key feature is a search optimization based on partitions and allows Zilliz Cloud to distribute entities into different partitions based on the values in a specific scalar field. This feature helps implement partition-oriented multi-tenancy and improves search performance.

This feature will not be discussed on this page. To find more, refer to Use Partition Key.

List Partitions

When creating a collection, Zilliz Cloud also creates a partition named _default in the collection. You can list the partitions in a collection as follows.

from pymilvus import MilvusClient

client = MilvusClient(
uri="YOUR_CLUSTER_ENDPOINT",
token="YOUR_CLUSTER_TOKEN"
)

res = client.list_partitions(
collection_name="quick_setup"
)

print(res)

# Output
#
# ["_default"]

Create Partition

You can add more partitions to the collection and insert entities into these partitions based on certain criteria.

client.create_partition(
collection_name="quick_setup",
partition_name="partitionA"
)

res = client.list_partitions(
collection_name="quick_setup"
)

print(res)

# Output
#
# ["_default", "partitionA"]

Check for a Specific Partition

The following code snippets demonstrate how to check whether a partition exists in a specific collection.

res = client.has_partition(
collection_name="quick_setup",
partition_name="partitionA"
)

print(res)

# Output
#
# True

Load and Release Partitions

You can separately load or release one or certain partitions.

Load Partitions

You can separately load specific partitions in a collection. It is worth noting that the load status of a collection stays unloaded if there is an unloaded partition in the collection.

client.load_partitions(
collection_name="quick_setup",
partition_names=["partitionA"]
)

res = client.get_load_state(
collection_name="quick_setup",
partition_name="partitionA"
)

print(res)
# Output
#
# {
# "state": "<LoadState: Loaded>"
# }

Release Partitions

You can also release specific partitions.

client.release_partitions(
collection_name="quick_setup",
partition_names=["partitionA"]
)

res = client.get_load_state(
collection_name="quick_setup",
partition_name="partitionA"
)

print(res)

# Output
#
# {
# "state": "<LoadState: NotLoaded>"
# }

Data Operations Within Partitions

Insert and Delete Entities

You can perform insert, upsert, and delete operations in specific operations. For details, refer to

Search and Query

You can conduct searches and queries within specific partitions. For details, refer to

Drop Partition

You can drop partitions that are no longer needed. Before dropping a partition, ensure that the partition has been released.

client.release_partitions(
collection_name="quick_setup",
partition_names=["partitionA"]
)

client.drop_partition(
collection_name="quick_setup",
partition_name="partitionA"
)

res = client.list_partitions(
collection_name="quick_setup"
)

print(res)

# ["_default"]