Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6674575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:45:44+00:00 2026-05-26T03:45:44+00:00

I have a question that involves a performance question and Mongo Design. Currently a

  • 0

I have a question that involves a performance question and Mongo
Design. Currently a project I am working on will involve notifications
similar to Facebook where a user will receive messages on things that
happen in the site. The problem is choosing if notifications will be
either be its own collection or an array embedded within a user.
Requirements of notifications include:

  1. Changing the status from read/unread, and ordering by date(other
    sorting maybe later).
  2. Notifications are suppose to be in real time .
  3. Notifications are deleted every 2 weeks.

Correct my if I am wrong by my thinking is like this.

If the notifications are embedded in the user document, they will be
slower, more costly, and more time developing and harder to maintain\
because:

  1. For ordering and sorting, they will have to be map reduced for
    finding only the unread and ordering by a date. Or this can be done by
    PHP but is a more lengthily process.

  2. Updating/Deleting a notification record in an embedded array takes
    more time to find that document and can be prone to errors if an index
    of a notification has changed (IE: A new notification is push into the
    document).

  3. Notifications will be added to a queue in PHP and/or JavaScript for
    retrieval later. It will more time spent trying to figure out how to
    modify the queue(append/remove) because they will not have IDs.

If they are stored in their own collection and each notification has
its own id.

  1. No map reduce is required and it is easier to find and sort.

  2. Maybe possibly have performance issues if there are a lot of
    notifications(Is this true or false?).

  3. Easier to update queues because ids are present.

  4. Easier and can more reliably update and remove notifications
    because IDs do not change.

Can I get some feedback on this? Is my logic correct or incorrect?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:45:44+00:00Added an answer on May 26, 2026 at 3:45 am

    Both approaches works fine. But I have a similar functionality in my app, guess what, i also chose the second approach (Storing notifications in a seperate collection). Because of the 2 main reasons

    1. You cannot pick top n notifications when its embedded. Mongodb find picks the whole document irrespective of the filter. It ll return the whole document with all your notifications.

    2. And you cannot filter the relevant notifications when in embedded. Because of the above said same reason. Assume if you have 2 unread messages, you cannot ever pick the two messages alone, Irrespective of the filter it will return the whole document with all notifications. Assume what it ll do to your system when you have some 100 notifications. It ll blow.

    these two reasons are more than enough to avoid putting into embedded documents.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In this case, I'm working on a project that involves a database of library
I am working on a CMS that involves custom user pages. I have a
So I have a random question when coding the image processing function that involves
Question: I have a question that is apparently not answered by this already-asked Bash
I have a question that may be quite naive, but I feel the need
I have a question that I just don't feel like I've found a satisfactory
I have a question that I'm ashamed to ask, but I'm going to have
I have a simple question that I am posing mostly for my curiousity. What
I have a general question that is rather open-ended (i.e. depends on platform, application
I have this little question that's been on my mind for a while now.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.