Get Statistics
-
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. -
In this page:
Get collection statistics
To get collection statistics, use GetCollectionStatisticsOperation
:
// Pass an instance of class `GetCollectionStatisticsOperation` to the store
const stats = await store.maintenance.send(new GetCollectionStatisticsOperation());
Statistics are returned in the CollectionStatistics
object.
// 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
:
// 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.
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
const stats = await store.maintenance.send(new GetStatisticsOperation());
Statistics are returned in the DatabaseStatistics
object.
// 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
:
// Pass an instance of class `GetDetailedStatisticsOperation` to the store
const stats = await store.maintenance.send(new GetDetailedStatisticsOperation());
Statistics are returned in the DetailedDatabaseStatistics
object.
// 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.
// Get stats for 'AnotherDatabase':
const stats =
await store.maintenance.forDatabase("AnotherDatabase").send(new GetStatisticsOperation());
- Learn more about switching operations to another database here.