メインコンテンツまでスキップ

get_collection_stats()

Addedv2.3.xModifiedv2.6.x

This operation lists the statistics collected on a specific collection.

📘Notes

This method applies only to dedicated serving clusters and on-demand compute.

  • For a managed collection in serving clusters, please create MilvusClient with the cluster endpoint.

  • Free & Serverless

https://{cluster-id}.serverless.{region}.vectordb.zillizcloud.com

  • Dedicated

https://{cluster-id}.{region}.vectordb.zillizcloud.com:19530

  • For an external collection for on-demand compute, create MilvusClient with the project endpoints.

https://{project-id}.{region}.api.zillizcloud.com

Request Syntax

get_collection_stats(
collection_name: str,
timeout: Optional[float] = None,
**kwargs,
) -> Dict

PARAMETERS:

  • collection_name (str) -

    [REQUIRED]

    The name of a collection.

  • timeout (Optional[float]) -

    The timeout duration for this operation. Setting this to None indicates that this operation timeouts when any response returns or error occurs.

  • **kwargs -

    Additional keyword arguments for future extensibility.

RETURN TYPE:

dict

RETURNS:

A dictionary containing collected statistics on the specified collection.

{
'row_count': 0
}
📘Why doesn't the row count match the number of entities inserted?

The data you insert will undergo processing before it is finally saved. Initially, it will arrive as data streams. Then, it will be stored in segments as entities. Milvus will select an appropriate growing segment to store data in streams until it reaches its upper limit and becomes sealed.

However, note that the displayed row count may not match the number of records inserted, as stream data is not included.

Examples

from pymilvus import MilvusClient

client = MilvusClient(uri="YOUR_CLUSTER_ENDPOINT")

stats = client.get_collection_stats(
collection_name="my_collection"
)

print(stats)
# Output: {'row_count': 100}