Create MongoDB indexes

Description

Each service maintainer have to define which indexes should be created.
An index could be applied to one attribute (non on binary data type) or to multiple attributes at once. Please have a look at the documentation: https://docs.mongodb.com/v3.0/core/index-types/
Service maintainers have to go through their queries and have to detect which queries are important and which are used multiple times (in different functions). For the most important queries an index have to be created.
We will gather all indexes and combine them in one script.

Example: User service
Multiple queries are using the username. The query for getting a public profile is also using the username and will benefit from an index. Thus the index for this is db.users.createIndex({username: 1})
The sign in route is used very often - the query is using the email and password. Thus the following index is helpful: db.users.createIndex({email: 1, password: 1})

Updated Instructions:
In order to facilitate these indexes actually being applied, service maintainers that use nodejs with mongodb are now tasked to merge the most recent changes in the microservice template repo here: https://github.com/slidewiki/microservice-template. The changes specifically for this purpose are the ones in this (merged) PR: https://github.com/slidewiki/microservice-template/pull/6/files

Service maintainers simply need to update the code in file ` application/database/createIndexes.js` in order to apply the indexes. The service will then ensure the indexes are already created in the database on each service start and apply them if they do not exist.

100% Done
0

Activity

Kurt Junghanns September 6, 2017 at 10:13 AM

Please provide the indexes inside the ticket so that QA could be done. We will gather the indexes in the branch when the subtickets are closed.

Dejan Paunović September 6, 2017 at 9:55 AM

Should we add indexes for all services to this branch that mentions?

Kurt Junghanns September 4, 2017 at 7:41 AM

See branch new_script_for_MongoDB_indexing in slidewiki-deployment repo.

Done

Details

Assignee

Reporter

Priority

Who's Looking?

Open Who's Looking?

Created August 21, 2017 at 1:42 PM
Updated June 14, 2018 at 11:17 PM
Resolved June 14, 2018 at 11:17 PM
Who's Looking?

Flag notifications