imranmomin/Hangfire.AzureDocumentDB

get counts of jobs on state

Closed this issue · 3 comments

Hi @imranmomin ,
first of all, thanks for such a great job.
we have a very large database and we have found a problem in the method DocumentDbMonitoringApi.GetStatistics().
to retrieve the counters you have to read the entire database and the query takes about 4 min.

Changing to a query by state, the performance improves a lot, 1 sec.
so we have loaded the variable "result" reusing the method "GetNumberOfJobsByStateName"

results = keys.Select(x => new { Key = x.ToLower(), Value = GetNumberOfJobsByStateName(x) }).Where(x => x.Value > 0).ToDictionary(i => i.Key, i => i.Value);

image

@miguelEsteban - Yeah, this will reduce the time.

I have also, another repo for .NET Core where I have used the GroupBy within the query. Have a look if that works or else you can raise the PR for the current changes

https://github.com/imranmomin/Hangfire.AzureCosmosDb/blob/1ed52d4ff05c34ba11654ca20c27786bd2c2ee13/src/CosmosDbMonitoringApi.cs#L123

Accepted the #59
Thank you @miguelEsteban