Skip to content

[BUG] Optimize N+1 Queries in Event Recommendations #119

Description

@Shikigami1606

Describe the Bug

The getSimilarEventsBySlug() function appears to suffer from an N+1 query problem when fetching recommended events. Instead of retrieving similar events in a single optimized query, the implementation may perform multiple database calls, causing unnecessary overhead as the number of recommendations grows.

To Reproduce

  1. Open event.actions.ts.
  2. Inspect the implementation of getSimilarEventsBySlug().
  3. Observe that similar events are fetched through multiple database queries rather than a batched query.
  4. Note that the number of database calls increases with the number of recommended events.

Expected Behavior

Similar events should be fetched using a single optimized database query or aggregation pipeline to minimize database round trips and improve scalability.

Screenshots/Gifs

N/A

Environment (please complete the following information):

  • OS: Windows
  • Browser: Chrome
  • Node Version: 20.x

Additional Context

This optimization would improve performance and reduce database load, especially when the number of similar events grows. A potential solution is to replace multiple individual queries with a batched query using $in or redesign the logic using a MongoDB aggregation pipeline.

I'd like to work on this issue and submit a fix.
Can you please assign me this issue for SSoc

Metadata

Metadata

Assignees

Labels

MediumSSoC26TO CONTRIBUTEbugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions