Get Statistics



Get collection statistics

To get collection statistics, use GetCollectionStatisticsOperation:

# Pass an instance of class 'GetCollectionStatisticsOperation' to the store
stats = store.maintenance.send(GetCollectionStatisticsOperation())

Statistics are returned in the CollectionStatistics object.

class CollectionStatistics:
    def __init__(
        self,
        count_of_documents: Optional[int] = None,
        count_of_conflicts: Optional[int] = None,
        collections: Optional[Dict[str, int]] = None,
    ): ...

Get detailed collection statistics

To get detailed collection statistics, use GetDetailedCollectionStatisticsOperation:

# Pass an instance of class 'GetDetailedCollectionStatisticsOperation' to the store
stats = store.maintenance.send(GetDetailedCollectionStatisticsOperation())

Statistics are returned in the DetailedCollectionStatistics object.

class Size:
    def __init__(self, size_in_bytes: int = None, human_size: str = None): ...

class CollectionDetails:
    def __init__(
        self,
        name: str = None,
        count_of_documents: int = None,
        size: Size = None,
        documents_size: Size = None,
        tombstones_size: Size = None,
        revisions_size: Size = None,
    ): ...

class DetailedCollectionStatistics:
    def __init__(
        self,
        count_of_documents: int = None,
        count_of_conflicts: int = None,
        collections: Dict[str, CollectionDetails] = None,
    ) -> None: ...

Get database statistics

To get database statistics, use GetStatisticsOperation:

# Pass an instance of class 'GetStatisticsOperation' to the store
stats = store.maintenance.send(GetStatisticsOperation())

Statistics are returned in the DatabaseStatistics object.

class DatabaseStatistics:
    def __init__(
        self,
        last_doc_etag: int = None,
        last_database_etag: int = None,
        count_of_indexes: int = None,
        count_of_documents: int = None,
        count_of_revision_documents: int = None,
        count_of_documents_conflicts: int = None,
        count_of_tombstones: int = None,
        count_of_conflicts: int = None,
        count_of_attachments: int = None,
        count_of_unique_attachments: int = None,
        count_of_counter_entries: int = None,
        count_of_time_series_segments: int = None,
        indexes: List[IndexInformation] = None,
        database_change_vector: str = None,
        database_id: str = None,
        is_64_bit: bool = None,
        pager: str = None,
        last_indexing_time: datetime.datetime = None,
        size_on_disk: Size = None,
        temp_buffers_size_on_disk: Size = None,
        number_of_transaction_merger_queue_operations: int = None,
    ): ...

Get detailed database statistics

To get detailed database statistics, use GetDetailedStatisticsOperation:

# Pass an instance of class 'GetDetailedStatisticsOperation' to the store
stats = store.maintenance.send(GetDetailedStatisticsOperation())

Statistics are returned in the DetailedDatabaseStatistics object.

class DetailedDatabaseStatistics(DatabaseStatistics):
    def __init__(
        self,
        last_doc_etag: int = None,
        last_database_etag: int = None,
        count_of_indexes: int = None,
        count_of_documents: int = None,
        count_of_revision_documents: int = None,
        count_of_documents_conflicts: int = None,
        count_of_tombstones: int = None,
        count_of_conflicts: int = None,
        count_of_attachments: int = None,
        count_of_unique_attachments: int = None,
        count_of_counter_entries: int = None,
        count_of_time_series_segments: int = None,
        indexes: List[IndexInformation] = None,
        database_change_vector: str = None,
        database_id: str = None,
        is_64_bit: bool = None,
        pager: str = None,
        last_indexing_time: datetime.datetime = None,
        size_on_disk: Size = None,
        temp_buffers_size_on_disk: Size = None,
        number_of_transaction_merger_queue_operations: int = None,
        count_of_identities: int = None,  # Total # of identities in database
        count_of_compare_exchange: int = None,  # Total # of compare-exchange items in database
        count_of_compare_exchange_tombstones: int = None,  # Total # of cmpXchg tombstones in database
    ): ...

Get statistics for another database

  • By default, you get statistics for the database defined in your Document Store.
  • Use for_database to get database and collection statistics for another database.
  • for_database can be used with any of the above statistics options.

# Get stats for 'AnotherDatabase'
stats = store.maintenance.for_database("AnotherDatabase").send(GetStatisticsOperation())
  • Learn more about switching operations to another database here.