R
R
Roman2016-07-20 19:26:43
NoSQL
Roman, 2016-07-20 19:26:43

How to properly organize work with documents in MongoDB?

I scrape several sites every 5 seconds (PhantomJS), filter the results and put them into documents (PHP). The document looks something like this:

{
"_id" : ObjectId("578e68cb438ca09f7f02e21a"),
"key" {
    "Team1" : "Blue",
    "Team2" : "Red",
    "Archive": false,
        "1469026428" : {
                "Win1" : 1.67,
                "Draw" : 2.07,
                "Win2" : null
            }
}
}

The bottom line is that there comes a time when the document is "obsolete" and it needs to be marked as archived .
Which one is better:
  1. Mark one of the fields of the document, and when displaying information, focus on this field, thereby separating archival documents from fresh ones.
  2. Transfer to another document.
  3. Other?

UDP: I will be glad to any advice and guides.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
lega, 2016-07-20
@xii

If you don't need to output archived and simple ones together (in one request), then it's better to transfer them to another collection - you can save a lot on indexes (+ better read, write speed), archived ones can be moved to a slow, cheap server, etc.

N
napa3um, 2016-07-20
@napa3um

Option 1 is generally better.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question