• User Guide

Compact Data

This topic describes how to compact data in Milvus.

Milvus supports automatic data compaction by default. You can configure your Milvus to enable or disable compaction and automatic compaction.

If automatic compaction is disabled, you can still compact data manually.

To ensure accuracy of searches with Time Travel, Milvus retains the data operation log within the span specified in common.retentionDuration. Therefore, data operated within this period will not be compacted.

Compact data manually

Compaction requests are processed asynchronously because they are usually time-consuming.

from pymilvus import Collection
collection = Collection("book")      # Get an existing collection.
const res = await milvusClient.collectionManager.compact({
  collection_name: "book",
const compactionID = res.compactionID;
// This function is under active development on the GO client.
R<ManualCompactionResponse> response = milvusClient.manualCompaction(
long compactionID = response.getData().getCompactionID();
compact -c book
Parameter Description
collection_name Name of the collection to compact data.
Parameter Description
CollectionName Name of the collection to compact data.
Option Description
-c Name of the collection to compact data.

Check compaction status

You can check the compaction status with the compaction ID returned when the manual compaction is triggered.

const state = await milvusClient.collectionManager.getCompactionState({
// This function is under active development on the GO client.
show compaction_state -c book

What's next


Was this page helpful?