Manage Partitions

This topic describes how to manage partitions in Milvus.

Milvus allows you to divide the bulk of vector data into a small number of partitions. Search and other operations can then be limited to one partition to improve the performance.

A collection consists of one or more partitions. While creating a new collection, Milvus creates a default partition _default. See Glossary - Partition for more information.

The following example is based on a partition example_partition in the collection example_collection.

Create a partition

from pymilvus import Collection
collection = Collection("example_collection")      # Get an existing collection.
partition = collection.create_partition("example_partition")
await milvusClient.partitionManager.createPartition({
  collection_name: "example_collection",
  partition_name: "example_partition",
});
Parameter Description
partition_name Name of the partition to create.
description (optional) Description of the partition to create.
Parameter Description
collection_name Name of the collection to create a partition in.
partition_name Name of the partition to create.

List all partitions

from pymilvus import Collection
collection = Collection("example_collection")      # Get an existing collection.
collection.partitions
await milvusClient.partitionManager.showPartitions({
  collection_name: "example_collection",
});

Verify if a partition exist

from pymilvus import Collection
collection.has_partition("example_partition")
await milvusClient.partitionManager.hasPartition({
  collection_name: "example_collection",
  partition_name: "example_partition",
});

Drop a partition

Remove a partition.

The drop operation is irreversible. Dropping a partition deletes all data within it.
from pymilvus import Collection
collection.drop_partition("example_partition")
await milvusClient.partitionManager.dropPartition({
  collection_name: "example_collection",
  partition_name: "example_partition",
});

What's next

Is this page helpful?
Scored Successfully!