Statistics: Client API
-
Database and collection statistics can be retrieved using the client API.
-
By default, statistics are retrieved for the database defined in the Document Store.
To get database and collection statistics for another database use ForDatabase. -
In this article:
Get collection statistics
To get collection statistics, use GetCollectionStatisticsOperation:
// Pass an instance of GetCollectionStatisticsOperation to the store
CollectionStatistics stats =
store.Maintenance.Send(new GetCollectionStatisticsOperation());
The statistics are returned in a CollectionStatistics object:
public class CollectionStatistics
{
// Total number of documents in all collections
public long CountOfDocuments { get; set; }
// Total number of conflicts
public long CountOfConflicts { get; set; }
// Total number of revision documents
public long CountOfRevisionDocuments { get; set; }
// Total number of tombstones
public long CountOfTombstones { get; set; }
// Total number of time-series deleted ranges
public long CountOfTimeSeriesDeletedRanges { get; set; }
// Total number of document conflicts
public long CountOfDocumentsConflicts { get; set; }
// Total number of attachments
public long CountOfAttachments { get; set; }
// Total number of counter-group entries
public long CountOfCounterEntries { get; set; }
// Total number of time-series segments
public long CountOfTimeSeriesSegments { get; set; }
// Number of documents per collection
public Dictionary<string, long> Collections { get; set; }
}
Get detailed collection statistics
To get detailed collection statistics, use GetDetailedCollectionStatisticsOperation:
// Pass an instance of GetDetailedCollectionStatisticsOperation to the store
DetailedCollectionStatistics stats =
store.Maintenance.Send(new GetDetailedCollectionStatisticsOperation());
The statistics are returned in a DetailedCollectionStatistics object,
with a CollectionDetails entry per collection:
public class DetailedCollectionStatistics
{
// Total number of documents in all collections
public long CountOfDocuments { get; set; }
// Total number of conflicts
public long CountOfConflicts { get; set; }
// Total number of revision documents
public long CountOfRevisionDocuments { get; set; }
// Total number of tombstones
public long CountOfTombstones { get; set; }
// Total number of time-series deleted ranges
public long CountOfTimeSeriesDeletedRanges { get; set; }
// Total number of document conflicts
public long CountOfDocumentsConflicts { get; set; }
// Total number of attachments
public long CountOfAttachments { get; set; }
// Total number of counter-group entries
public long CountOfCounterEntries { get; set; }
// Total number of time-series segments
public long CountOfTimeSeriesSegments { get; set; }
// Details per collection
public Dictionary<string, CollectionDetails> Collections { get; set; }
}
public class CollectionDetails
{
public string Name { get; set; }
public long CountOfDocuments { get; set; }
public long CountOfTombstones { get; set; }
public long CountOfRevisions { get; set; }
public long CountOfTimeSeriesDeletedRanges { get; set; }
public long CountOfCounterEntries { get; set; }
public long CountOfTimeSeriesSegments { get; set; }
public Size TimeSeriesSegmentsSize { get; set; }
public Size Size { get; set; }
public Size DocumentsSize { get; set; }
public Size TombstonesSize { get; set; }
public Size RevisionsSize { get; set; }
public Size TimeSeriesDeletedRangesSize { get; set; }
public Size CounterEntriesSize { get; set; }
}
Get database statistics
To get database statistics, use GetStatisticsOperation:
// Pass an instance of GetStatisticsOperation to the store
DatabaseStatistics stats =
store.Maintenance.Send(new GetStatisticsOperation());
The statistics are returned in a DatabaseStatistics object:
public class DatabaseStatistics
{
// Last document etag in the database
public long? LastDocEtag { get; set; }
// Last database etag
public long? LastDatabaseEtag { get; set; }
// Total number of indexes in the database
public int CountOfIndexes { get; set; }
// Total number of documents in the database
public long CountOfDocuments { get; set; }
// Total number of revision documents in the database
public long CountOfRevisionDocuments { get; set; }
// Total number of document conflicts in the database
public long CountOfDocumentsConflicts { get; set; }
// Total number of tombstones in the database
public long CountOfTombstones { get; set; }
// Total number of conflicts in the database
public long CountOfConflicts { get; set; }
// Total number of counter-group entries in the database
public long CountOfCounterEntries { get; set; }
// Total number of time-series segments in the database
public long CountOfTimeSeriesSegments { get; set; }
// Total number of attachments in the database (local and remote)
public long CountOfAttachments { get; set; }
// Total number of unique attachments in the database (local only)
public long CountOfUniqueAttachments { get; set; }
// Names of the stale indexes in the database
public string[] StaleIndexes => Indexes?.Where(x => x.IsStale).Select(x => x.Name).ToArray();
// Statistics for each index in the database
public IndexInformation[] Indexes { get; set; }
// Global change vector of the database
public string DatabaseChangeVector { get; set; }
// Database identifier
public string DatabaseId { get; set; }
// Indicates whether the process is 64-bit
public bool Is64Bit { get; set; }
// Component handling the memory-mapped files
public string Pager { get; set; }
// Last time an item was indexed
public DateTime? LastIndexingTime { get; set; }
// Database size on disk
public Size SizeOnDisk { get; set; }
// Temp buffers size on disk
public Size TempBuffersSizeOnDisk { get; set; }
// Number of transaction-merger queue operations
public int NumberOfTransactionMergerQueueOperations { get; set; }
}
Get detailed database statistics
To get detailed database statistics, use GetDetailedStatisticsOperation:
// Pass an instance of GetDetailedStatisticsOperation to the store
DetailedDatabaseStatistics stats =
store.Maintenance.Send(new GetDetailedStatisticsOperation());
DetailedDatabaseStatistics extends DatabaseStatistics with additional counts:
public class DetailedDatabaseStatistics : DatabaseStatistics
{
// Total number of identities in the database
public long CountOfIdentities { get; set; }
// Total number of compare-exchange values in the database
public long CountOfCompareExchange { get; set; }
// Total number of compare-exchange tombstones in the database
public long CountOfCompareExchangeTombstones { get; set; }
// Total number of time-series deleted ranges in the database
public long CountOfTimeSeriesDeletedRanges { get; set; }
// Total number of remote attachments in the database
public long CountOfRemoteAttachments { get; set; }
}
Get statistics for another database
- By default, you get statistics for the database defined in your Document Store.
- Use
ForDatabaseto get database and collection statistics for another database. ForDatabasecan be used with any of the statistics options shown above.
// Get statistics for 'AnotherDatabase':
DatabaseStatistics stats =
store.Maintenance.ForDatabase("AnotherDatabase").Send(new GetStatisticsOperation());
Learn more about switching operations to another database.