Skip to content

DB Indexes

a-a-hofmann edited this page Dec 4, 2019 · 1 revision

As the number of submissions increases, a query such as "fetch the last submission for user1 for exercise1" became very sluggish due to the database having to scan all rows to find any matches.

To counter this we added indexes: https://docs.mongodb.com/manual/indexes/

In particular indexes where added to the userId, exerciseId and the compounded (userId, exerciseId) fields. This drastically improved query speed from about 800ms to under 40ms.