English 中文(简体)
MongoDB/NoSQL 业绩和设计
原标题:MongoDB/NoSQL Performance and Design

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.

我认为,如果我错的话,我就不明白了。

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. 不需要减少地图,更容易找到和分类。

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

  3. 由于有女婴,请更新询问。

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

我能否得到这方面的一些反馈? 我的逻辑是否正确?

最佳回答

这两种做法都很出色。 但我在评估中具有类似功能,猜测了什么,也选择了第二种方法(在收集精良时保存通知)。 由于两个主要原因

  1. 当通知根植时,你不能取上一级。 不管过滤器如何,Mongodb发现了整个文件。 随所有通知将整个文件退回。

  2. 当有关通知被封存时,你不能过滤。 由于上述原因。 如果你有两条不易读的信息,你就永远不能只拿两条信息,不管过滤器如何,它会把整个文件与所有通知一并退回。 当你收到约100份通知时,就算出对你的系统的影响。 这起爆炸。

这两项原因足以避免将文件编成内。

问题回答

暂无回答




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

难以执行 REGEXP_SUBSTR

I m 查询Oracle 10g。 我有两张表格(样本数据见下文)。 i m 试图提取一些领域

SQL Query Shortcuts

What are some cool SQL shorthands that you know of? For example, something I learned today is you can specify to group by an index: SELECT col1, col2 FROM table GROUP BY 2 This will group by col2

PHP array callback functions for cleaning output

I have an array of output from a database. I am wondering what the cleanest way to filter the values is example array Array ( [0] => Array ( [title] => title 1 ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

Running numbers in SQL

I have a SQL-statement like this: SELECT name FROM users WHERE deleted = 0; How can i create a result set with a running number in the first row? So the result would look like this: 1 Name_1 2 ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签