AI

Release a Collection From Memory in Milvus

In Milvus, releasing a collection refers to moving a collection that is loaded into the memory back to the system storage.

Before we can query the data that is stored in the collection, we need to ensure that the collection is loaded into the memory.

Therefore, before we can query the data that is stored in the collection, we need to load the collection into the memory.

However, once we are done in performing all the operations on the collection, we need to release the collection from the system memory to the system storage.

In this tutorial, we will learn how to release a loaded collection using the Milvus CLI and the Attu server manager.

How Does the Collection Loading Works?

Before we get to the commands on loading the Milvus collection, let us explore what exactly happens during the collection load.

Loading a collection involves loading the metadata that is associated with the collection such as the schema, indexing configurations, and other settings. In addition, it involves loading the vector data from the storage system into the memory for quick and efficient data query and processing.

Creating a Milvus Collection

Before learning how to load and release a Milvus collection, let us start by setting up a sample Milvus collection for demonstration purposes.

Start by opening the Milvus CLI with the following command:

$ milvus_cli

Next, login to your Milvus instance with the following command:

milvus_cli > connect -h <host> -p <port> -a <alias>

For example, the following command logs into a locally hosted Milvus instance on the default port and alias:

milvus_cli > connect -h 127.0.0.1 -p 19530 -a default

Output:

Connect Milvus successfully.
+---------+---------------------+
| Address | 192.168.100.2:19530 |
| User | |
| Alias | default |

Once logged in, we can create a sample Milvus collection as shown in the following command:

milvus_cli > create collection -c film -f id:INT64:primary_field -f film_name:VARCHAR:100 -f release_year:INT64:release_year -f vector:FLOAT_VECTOR:8 -p id -d 'fiml_collection'

The given command should create a simple collection called “film” which we can use for demonstration purposes.

Load a Collection in Milvus

The CLI provides us with a set of commands that are easy to use which allows us to quickly and efficiently manage the database from a CLI interface.

To load a database in Milvus, we can use the load command as shown in the following syntax:

$ load -c (text) [-p (text)]

Where -c denotes the collection name and -p denotes the partition name.

NOTE: The “load” command allows us to load a collection or a partition to memory.

For example, we can run the following query to load the “film” collection into the memory.

milvus_cli > load -c film

The previous command loads the “film” collection into the memory and allows you to search the stored data.

Load Collection film successfully
+-------------------+----------+---------+
| Collection Name | Loaded | Total |
+===================+==========+=========+
| film | | |
+-------------------+----------+---------+

NOTE: The command may require you to create an index on your target collection.

To learn more about collection loading in Milvus, check the tutorial on https://linuxhint.com/milvus-load-collection.

Release a Collection Using the Milvus CLI

To release a collection, we can use the “release” command in the Milvus CLI as shown in the following syntax:

release -c (text) [-p (text)]

Where the -c parameter denotes the collection name and the -p option specifies the partition name.

For example, to release the film collection, we can use the following command:

milvus_cli > release -c film

Release a Collection Using Attu

If you are using the Attu manager, you can release a collection by navigating to the “loaded collections” pane on the left-hand pane.

This should list all the loaded collections in the server. Next, locate the database that you wish to release and click the “release” icon.

Upon a successful release of collection, you should see a notification which indicates that the collection has been released from the memory.

Conclusion

We explored how we can use the Milvus CLI to load a database collection. We also learned how to use the Milvus CLI and the Attu manager to release a collection from the memory.

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list