talk icon indicating copy to clipboard operation
talk copied to clipboard

Create an index for collection commentActions, with fields: userID, tenantID, actionType, since it's showing a performance issue

Open HectorNM opened this issue 4 years ago • 0 comments
trafficstars

Search Terms

commentActions, index

Suggestion

We are dealing with millions of comments in production, and we noticed that queries for user deletion are taking too long (a few minutes). During deletion, a lot of queries are made to mongo and there are a lot of indexes for them, but we noticed that there is a query in commentActions using fields userID, tenantID, actionType that doesn't seem to have an index. Trying to run only this find query in the same production database, we noticed that it took a long time (a few minutes), so we suspect the absence of an index is causing this. Would you consider creating an index for these fields? We doesn't know the impact on write operations, but we think it's probably low.

Use Cases

This improves performance when accessing database, mainly for large databases. A shortcoming of a new index is to turn write operations on these fields a little more expensive, but we believe that it's not a huge impact and it's worth it.

HectorNM avatar Dec 08 '20 20:12 HectorNM