---
title: "Get Statistics"
url: "https://docs.ravendb.net/6.2/client-api/operations/maintenance/get-stats"
version: "6.2"
language: "python"
---

# Get Statistics

> Client language: Python. Also available for [C#](https://docs.ravendb.net/6.2/client-api/operations/maintenance/get-stats.md), [Java](https://docs.ravendb.net/6.2/client-api/operations/maintenance/get-stats.java.md), [PHP](https://docs.ravendb.net/6.2/client-api/operations/maintenance/get-stats.php.md), [Node.js](https://docs.ravendb.net/6.2/client-api/operations/maintenance/get-stats.nodejs.md).
>
> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

> **Note**
>
> - Statistics can be retrieved for the database and for collections.
>
> - By default, statistics are retrieved for the database defined in the Document Store.  
>   To get database and collection statistics for another database use [for\_database](#get-stats-for-another-database).
>
> - In this page:
>   - [Get collection statistics](#get-collection-statistics)
>   - [Get detailed collection statistics](#get-detailed-collection-statistics)
>   - [Get database statistics](#get-database-statistics)
>   - [Get detailed database statistics](#get-detailed-database-statistics)
>   - [Get statistics for another database](#get-statistics-for-another-database)

## Get collection statistics

To get **collection statistics**, use `GetCollectionStatisticsOperation`:

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

Statistics are returned in the `CollectionStatistics` object.

```python
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`:

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

Statistics are returned in the `DetailedCollectionStatistics` object.

```python
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`:

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

Statistics are returned in the `DatabaseStatistics` object.

```python
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`:

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

Statistics are returned in the `DetailedDatabaseStatistics` object.

```python
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.

```python
# Get stats for 'AnotherDatabase'
stats = store.maintenance.for_database("AnotherDatabase").send(GetStatisticsOperation())
```

- Learn more about switching operations to another database [here](https://docs.ravendb.net/6.2/client-api/operations/how-to/switch-operations-to-a-different-database.python.md).

## See also

- [What are Operations](https://docs.ravendb.net/6.2/client-api/operations/what-are-operations.python.md)
- [Switch operation to another database](https://docs.ravendb.net/6.2/client-api/operations/how-to/switch-operations-to-a-different-database.python.md)
- [What is a Collection](https://docs.ravendb.net/6.2/client-api/faq/what-is-a-collection.md)
- [Get Query Statistics](https://docs.ravendb.net/6.2/client-api/session/querying/how-to-get-query-statistics.python.md)
