Get Query Statistics
Query statistics can provide important information about a query like duration, total number of results, staleness information, etc. To access statistics use the statistics()
method.
Syntax
query.statistics(statsCallback);
Parameters | ||
---|---|---|
statsCallback | (stats) => void |
Callback passing the QueryStatistics object for query. |
Example
let stats;
const employees = await session.query({ collection: "Employees" })
.whereEquals("FirstName", "Robert")
.statistics(s => stats = s)
.all();
const totalResults = stats.value.totalResults;
const durationInMs = stats.value.durationInMs;
// QueryStatistics {
// isStale: false,
// durationInMs: 744,
// totalResults: 1,
// skippedResults: 0,
// timestamp: 2018-09-24T05:34:15.260Z,
// indexName: 'Auto/Employees/ByFirstName',
// indexTimestamp: 2018-09-24T05:34:15.260Z,
// lastQueryTime: 2018-09-24T05:34:15.260Z,
// resultEtag: 8426908718162809000 }