V
V
Vlad Timofeev2015-01-16 16:28:24
MongoDB
Vlad Timofeev, 2015-01-16 16:28:24

Which database model will be more efficient in terms of performance?

Good day, I have a Post model that has an author field .
So, what will be faster and more correct to use?

  1. When posting a request to create news, save all information about the author (id, name, ect ..) in the author field
  2. Or, when posting a request, save only id in the author field, and then use the User.find({'id':post.author.id}) method when rendering

Thanks for the advice.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Artem, 2015-01-16
@PyTiMa

The first option doesn't work at all. See docs.mongodb.org/master/MongoDB-data-models-guide.pdf

S
Sergey Krasnodemsky, 2015-01-16
@Prognosticator

First

L
lega, 2015-01-16
@lega

You can also consider a ("hardcore") option (may be suitable for some cases):
We store the author's identifier in the post, sends the post to the client as is, and on the client we substitute the author from the cache, if not in the cache, then load it from the server.
As they said above, it's too early to optimize, so for starters, I would take option 2.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question