Question

What metrics should I use to decide whether I want to structure my document like:

{ count: { comments: Integer, views: Integer } }

vs.

{ commentCount: Integer, viewCount: Integer }

Since indexing count.comments vs. commentCount and querying on both is essentially equivalent, which structure would make sense in this situation?

Was it helpful?

Solution

Typically that will depend on how many writes/reads you are going to perform over the collection, in the case of you're going to update the counts for views and comments very often I'd suggest to go with a plain approach, other downside is that I look for creating a child complex type is the level of verbosity, if creating those kind of objects are not completely required try to keep it as much simple as possible, the queries would be a lot of easier to implement in more complex scenarios.

my two cents.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top