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

# Get Statistics

> Client language: Node.js. 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), [Python](https://docs.ravendb.net/6.2/client-api/operations/maintenance/get-stats.python.md), [PHP](https://docs.ravendb.net/6.2/client-api/operations/maintenance/get-stats.php.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 [forDatabase](#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`:

```javascript
// Pass an instance of class `GetCollectionStatisticsOperation` to the store 
const stats = await store.maintenance.send(new GetCollectionStatisticsOperation());
```

Statistics are returned in the `CollectionStatistics` object.

```javascript
// Object with following props is returned:
{
  // Total # of documents in all collections
  countOfDocuments,
  // Total # of conflicts
  countOfConflicts,
  // Dictionary with total # of documents per collection
  collections
}
```

## Get detailed collection statistics

To get **detailed collection statistics**, use `GetDetailedCollectionStatisticsOperation`:

```javascript
// Object with following props is returned:
{
  // Total # of documents in all collections
  countOfDocuments,
  // Total # of conflicts
  countOfConflicts,
  // Dictionary with 'collection details per collection'
  collections,
}

// 'Collection details per collection' object props:
{
  name,
  countOfDocuments,
  size,
  documentsSize,
  tombstonesSize,
  revisionsSize
}
```

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

```javascript
// Pass an instance of class `GetStatisticsOperation` to the store 
const stats = await store.maintenance.send(new GetStatisticsOperation());
```

Statistics are returned in the `DatabaseStatistics` object.

```javascript
// Object with following props is returned:
{
  lastDocEtag,      // Last document etag in database
  lastDatabaseEtag, // Last database etag
  
  countOfIndexes,            // Total # of indexes in database
  countOfDocuments,          // Total # of documents in database
  countOfRevisionDocuments,  // Total # of revision documents in database
  countOfDocumentsConflicts, // Total # of documents conflicts in database 
  countOfTombstones,         // Total # of tombstones in database
  countOfConflicts,          // Total # of conflicts in database
  countOfAttachments,        // Total # of attachments in database
  countOfUniqueAttachments,  // Total # of unique attachments in database
  countOfCounterEntries,     // Total # of counter-group entries in database
  countOfTimeSeriesSegments, // Total # of time-series segments in database
  
  indexes, // Statistics for each index in database (array of IndexInformation) 

  databaseChangeVector,  // Global change vector of the database
  databaseId,            // Database identifier
  is64Bit,               // Indicates if process is 64-bit 
  pager,                 // Component handling the memory-mapped files
  lastIndexingTime,      // Last time of indexing an item
  sizeOnDisk,            // Database size on disk
  tempBuffersSizeOnDisk, // Temp buffers size on disk
  numberOfTransactionMergerQueueOperations
}
```

## Get detailed database statistics

To get **detailed database statistics**, use `GetDetailedStatisticsOperation`:

```javascript
// Pass an instance of class `GetDetailedStatisticsOperation` to the store 
const stats = await store.maintenance.send(new GetDetailedStatisticsOperation());
```

Statistics are returned in the `DetailedDatabaseStatistics` object.

```javascript
// Resulting object contains all database stats props from above and the following in addition:
{
  // Total # of identities in database
  countOfIdentities,
  // Total # of compare-exchange items in database
  countOfCompareExchange,
  // Total # of cmpXchg tombstones in database
  countOfCompareExchangeTombstones,
  // Total # of TS deleted ranges values in database
  countOfTimeSeriesDeletedRanges
}
```

## Get statistics for another database

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

```javascript
// Get stats for 'AnotherDatabase':
const stats = 
  await store.maintenance.forDatabase("AnotherDatabase").send(new 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.nodejs.md).

## See also

- [What are Operations](https://docs.ravendb.net/6.2/client-api/operations/what-are-operations.nodejs.md)
- [Switch operation to another database](https://docs.ravendb.net/6.2/client-api/operations/how-to/switch-operations-to-a-different-database.nodejs.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.nodejs.md)
