Automattic / Automattic/mongoose

Performance improvement proposal for mongoose Query streams

Open
#7,094 1 comment 2 reactions 0 assignees View on GitHub
performance
Dominant language
JavaScript
Stars
27.5k
Forks
4k
Avg merge
2d 7h
Merged PRs (30d)
35

Description

I've benchmarked mongoose streams against mongodb streams and found mongoose was one order of magnitude slower.

I think there is a performance problem on current implementation, relying on continuously using mongo's cursor.next along with non-trivial flow control code to mongoosify returned documents.

IMHO, using an streaming approach involving mongo's Cursor.pipe along with stream's Transform, thus leveraging the flow control entirely to the efficient Readable.pipe interface, will result on much better numbers and, maybe, simpler code.

Contributor guide

Open the contributing guide

Research direction

No files or tests are named. Start by reproducing the benchmark comparing Mongoose and MongoDB streams, then inspect the current cursor.next flow-control and document-conversion path; done means validating whether a Cursor.pipe-based approach improves the reported performance without losing stream behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, mongodb, nodejs
Domain
databases, performance
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.