Optimize Mongodb aggregates
Omar Hussain

Omar Hussain @satansly

About: Your TL;DR buddy

Location:
Islamabad, Pakistan
Joined:
Jun 2, 2018

Optimize Mongodb aggregates

Publish Date: Dec 21 '21
0 0

NoSql queries can quickly become time consuming if queries rely on relating data across collections with large datasets.

You may be running into query time outs trying to generate a report on data.

In order to minimize the data query has to look through(hence time) do these two steps(if applicable) on every stage

$project

$project only fields that will be needed in proceeding stages.

$match

Narrow down data before $lookup and $group or after $unwind using $match

Yep thats it. If there is anything you do to optimize your aggregate piplines or know of a better way. Teach me!

Comments 0 total

    Add comment