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

# Get Statistics

> Client language: Java. Also available for [C#](https://docs.ravendb.net/6.2/client-api/operations/maintenance/get-stats.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), [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 [ForDatabase](#get-stats-for-another-database).
>
> - In this page:
>   - [Get collection stats](#get-collection-stats)
>   - [Get detailed collection stats](#get-detailed-collection-stats)
>   - [Get database stats](#get-database-stats)
>   - [Get detailed database stats](#get-detailed-database-stats)
>   - [Get stats for another database](#get-stats-for-another-database)

## Get collection stats

> **Note**
>
> Use `GetCollectionStatisticsOperation` to get **collection stats**.
>
> ```java
> // Pass an instance of class `GetCollectionStatisticsOperation` to the store 
> CollectionStatistics stats =
>   store.maintenance().send(new GetCollectionStatisticsOperation());
> ```

> **Note**
>
> Stats are returned in the `CollectionStatistics` object.
>
> ```java
> public class CollectionStatistics {
> // Collection stats results:
>   // Total # of documents in all collections
>   int CountOfDocuments;
>   // Total # of conflicts
>   int CountOfConflicts;
>   // Total # of documents per collection
>   Map<String, Long> Collections;
> }
> ```

## Get detailed collection stats

> **Note**
>
> Use `GetDetailedCollectionStatisticsOperation` to get **detailed collection stats**.
>
> ```java
> // Pass an instance of class `GetDetailedCollectionStatisticsOperation` to the store 
> DetailedCollectionStatistics stats =
>   store.maintenance().send(new GetDetailedCollectionStatisticsOperation());
> ```

> **Note**
>
> Stats are returned in the `DetailedCollectionStatistics` object.
>
> ```java
> // Detailed collection stats results:
> public class DetailedCollectionStatistics  {
>   // Total # of documents in all collections
>   long CountOfDocuments;
>   // Total # of conflicts
>   long CountOfConflicts;
>   // Collection details per collection
>   Map<String, CollectionDetails> Collections;
> }
>
> // Details per collection
> public class CollectionDetails {
>   String Name;
>   long CountOfDocuments;
>   Size Size;
>   Size DocumentsSize;
>   Size TombstonesSize;
>   Size RevisionsSize;
> }
> ```

## Get database stats

> **Note**
>
> Use `GetStatisticsOperation` to get **database stats**.
>
> ```java
> // Pass an instance of class `GetStatisticsOperation` to the store 
> DatabaseStatistics stats =
>   store.maintenance().send(new GetStatisticsOperation());
> ```

> **Note**
>
> Stats are returned in the `DatabaseStatistics` object.
>
> ```java
> // Database stats results:
> public class DatabaseStatistics {
>   Long LastDocEtag;       // Last document etag in database
>   Long LastDatabaseEtag;  // Last database etag
>   
>   int CountOfIndexes;     // Total # of indexes in database
>   long CountOfDocuments;  // Total # of documents in database
>   long CountOfRevisionDocuments;  // Total # of revision documents in database
>   long CountOfDocumentsConflicts; // Total # of documents conflicts in database
>   long CountOfTombstones;         // Total # of tombstones in database
>   long CountOfConflicts;          // Total # of conflicts in database
>   long CountOfAttachments;        // Total # of attachments in database
>   long CountOfUniqueAttachments;  // Total # of unique attachments in database
>   long CountOfCounterEntries;     // Total # of counter-group entries in database
>   long CountOfTimeSeriesSegments; // Total # of time-series segments in database
>
>   IndexInformation[] Indexes;     // Statistics for each index in database
>
>   String DatabaseChangeVector;    // Global change vector of the database
>   String DatabaseId;              // Database identifier
>   boolean Is64Bit;                // Indicates if process is 64-bit
>   String Pager;                   // Component handling the memory-mapped files
>   Date LastIndexingTime;          // Last time of indexing an item
>   Size SizeOnDisk;                // Database size on disk
>   Size TempBuffersSizeOnDisk;     // Temp buffers size on disk
>   int NumberOfTransactionMergerQueueOperations;
> }
> ```

## Get detailed database stats

> **Note**
>
> Use `GetDetailedStatisticsOperation` to get **detailed database stats**.
>
> ```java
> // Pass an instance of class `GetDetailedStatisticsOperation` to the store 
> DetailedDatabaseStatistics stats =
>   store.maintenance().send(new GetDetailedStatisticsOperation());
> ```

> **Note**
>
> Stats are returned in the `DetailedDatabaseStatistics` object.
>
> ```java
> // Detailed database stats results:
> public class DetailedDatabaseStatistics extends DatabaseStatistics {
>   // Total # of identities in database
>   long CountOfIdentities;
>   // Total # of compare-exchange items in database
>   long CountOfCompareExchange;
>   // Total # of cmpXchg tombstones in database
>   long CountOfCompareExchangeTombstones;
>   // Total # of TS deleted ranges values in database
>   long CountOfTimeSeriesDeletedRanges;
> }
> ```

## Get stats for another database

> **Note**
>
> - By default, you get stats for the database defined in your Document Store.
> - Use `forDatabase` to get database & collection stats for another database.
> - 'ForDatabase' can be used with **any** of the above stats options.
>
> ```java
> // Get stats for 'AnotherDatabase':
> DatabaseStatistics stats =
>   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.java.md).

## See also

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