< Docs
  • Java


A MilvusClient interface. This method shows the statistical information of the specified collection.

the current version only returns the row count of a collection. this method can be deprecated in the future.

R<GetCollectionStatisticsResponse> getCollectionStatistics(GetCollectionStatisticsParam requestParam);


Use the GetCollectionStatisticsParam.Builder to construct a GetCollectionStatisticsParam object.

import io.milvus.param.GetCollectionStatisticsParam;
GetCollectionStatisticsParam.Builder builder = GetCollectionStatisticsParam.newBuilder();

Methods of GetCollectionStatisticsParam.Builder:

Method Description Parameters
withCollectionName(String collectionName) Sets the collection name. Collection name cannot be empty or null. collectionName: The name of the collection whose statistical information needs to be checked.
withFlush(Boolean flush) Requests a flush action before retrieving collection statistics. The default value is False. flush: Set the value to true to perform a flush action.
build() Constructs a GetCollectionStatisticsParam object. N/A

The can throw the following exceptions:

  • ParamException: error if the parameter is invalid.


This method catches all the exceptions and returns an R<GetCollectionStatisticsResponse> object.

  • If the API fails on the server side, it returns the error code and message from the server.

  • If the API fails by RPC exception, it returns R.Status.Unknown and the error message of the exception.

  • If the API succeeds, it returns a valid GetCollectionStatisticsResponse held by the R template. You can use GetCollStatResponseWrapper to get the information.


A tool class to encapsulate the GetCollectionStatisticsResponse.

import io.milvus.response.GetCollStatResponseWrapper;
GetCollStatResponseWrapper wrapper = new GetCollStatResponseWrapper(getStatResponse);

Methods of GetCollStatResponseWrapper:

Method Description Parameters Returns
Gets the row count of a collection. Note that due to technical reasons, the deleted entities are not counted in the row count. N/A


import io.milvus.param.*;
import io.milvus.response.GetCollStatResponseWrapper;
import io.milvus.grpc.GetCollectionStatisticsResponse;

GetCollectionStatisticsParam param = GetCollectionStatisticsParam.newBuilder()
R<GetCollectionStatisticsResponse> response = client.getCollectionStatistics(param);
if (response.getStatus() != R.Status.Success.getCode()) {

GetCollStatResponseWrapper wrapper = new GetCollStatResponseWrapper(response.getData());
System.out.println("Row count: " + wrapper.getRowCount());