In Milvus, partitions divide the data into different logical categories. The resulting partitions allow us to segment that stored data effectively, making the data management and searching more efficient.
For example, suppose you have a vector database that stores millions of images. We can partition the images dataset based on the type of images such as landscape, portraits, animals, etc. The partitions allow us to perform the search operations within a specific partition much faster than searching the entire dataset.
In this tutorial, we will learn how to configure a partition and then use the Milvus CLI to gather a detailed information about the resulting partition.
Requirements:
Before proceeding with this tutorial, ensure that the following tools and packages are installed on your system:
- Milvus database server, local or remote
- Milvus CLI utility
Create a Partition Using Milvus CLI
To create a partition for a given collection using the Milvus CLI utility, we can use the “create partition” command as shown in the following syntax:
The parameters of the previous command are explained as follows:
-c – It denotes the collection name on which you wish to create the partition.
-p – It allows you to specify the name of your target partition.
-d – This is an optional parameter that denotes the description of the target partition.
Let us demonstrate how to create a new Milvus partition using the Milvus CLI.
Start by creating a basic Milvus collection as shown in the following command:
color -f brand:INT64:brand id -a -d 'car_collection'
The previous command creates a new collection in Milvus called “car” with four fields: id, vector, color, and brand. The id field is the primary field and partition key.
You can also allow Milvus to configure a default partition when creating a collection using the -p parameter.
However, to manually create a new partition, we can run the command as follows:
The previous command creates a new partition called “new_partition” on the “car” collection with the description of “sample_partition”.
Resulting Output:
| Partition Name | new_partition |
+--------------------+---------------+
| Description | |
+--------------------+---------------+
| Is empty | True |
+--------------------+---------------+
| Number of Entities | 0 |
+--------------------+---------------+
Create partition successfully!
Get the Partition Information in Milvus
Once you created the partition, you can gather a detailed information using the “describe partition” command.
The command syntax is as follows:
The -c parameter denotes the collection name, while the -p parameter denotes the target partition name.
For example, to gather an information about the “new_partition” partition that we created in the previous step, we can run the following query:
This command should return the partition information such as the number of entities in the partition, description, empty status, and more.
Conclusion
We learned about the “describe partition” command which allows us to gather an information about an existing Milvus partition. Consider the documentation to discover the command implementation.