milvus-logo
LFAI
Home
  • User Guide

Create a Partition

This topic describes how to create a partition 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.

When interacting with Milvus using Python code, you have the flexibility to choose between PyMilvus and MilvusClient (new). For more information, refer to Python SDK.

The following example builds a partition novel in the collection book.

from pymilvus import Collection
collection = Collection("book")      # Get an existing collection.
collection.create_partition("novel")
await milvusClient.createPartition({
  collection_name: "book",
  partition_name: "novel",
});
err := milvusClient.CreatePartition(
  context.Background(),   // ctx
  "book",                 // CollectionName
  "novel",                // partitionName
)
if err != nil {
  log.Fatal("failed to create partition:", err.Error())
}
milvusClient.createPartition(
  CreatePartitionParam.newBuilder()
    .withCollectionName("book")
    .withPartitionName("novel")
    .build()
);
create partition -c book -p novel
curl -X 'POST' \
  'http://localhost:9091/api/v1/partition' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
    "collection_name": "book",
    "partition_name": "novel"
  }'
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.
Parameter Description
ctx Context to control API invocation process.
CollectionName Name of the collection to create a partition in.
partitionName Name of the partition to create.
Parameter Description
CollectionName Name of the collection to create a partition in.
PartitionName Name of the partition to create.

Limits

FeatureMaximum limit
Number of partitions in a collection4,096

What’s next

Try Managed Milvus for Free

Zilliz Cloud is hassle-free, powered by Milvus and 10x faster.

Get Started
Feedback

Was this page helpful?