imranmomin / Hangfire.AzureCosmosDb

Azure Cosmos DB storage provider for Hangfire
https://www.hangfire.io/
MIT License
17 stars 16 forks source link

fix: query performance #56

Closed luisms89 closed 1 year ago

luisms89 commented 1 year ago

After deploying our application we found some Hangfire collections with lot of 429's errors. Our DB team has suggested the following changes:

1. Below query would benefit from adding the following composite index on both collections: ["\/type ASC","\/key ASC","\/score ASC"]

{"query":"SELECT TOP 1000.2 VALUE r1['p2']\nFROM r1\nWHERE ((r1.p1 = @param1) AND (r1.p3 BETWEEN @param2 AND @param3))\nORDER BY r1.p3","parameters":[{"name":"@param1","value":"str1"},{"name":"@param2","value":0},{"name":"@param3","value":1700100000}]}

2. We have observed that status 429 error code on below query

*{"query":"SELECT FROM doc WHERE IS_DEFINED(doc.expire_on) AND doc.expire_on < 1694454340","parameters":[]}**

As recommended by Microsoft can this be rewritten more optimally as below:

{"query":"SELECT * FROM doc WHERE doc.expire_on < 1694454340","parameters":[]}

In the following picture you can see the improvements after applying the changes:

image

Additional changes Also, I removed "noStrictGenericChecks": true from tsconfig.json because the pipeline was failing but I am not sure about the implications. Let me know if you have any concerns.

imranmomin commented 1 year ago

Thank you @luisms89

imranmomin commented 1 year ago

@luisms89 - I have released a new NuGet package.