@@ -112,6 +112,10 @@ Consider the following features of this schema:
112
112
sub-document, so that you may iterate the schema can evolve as
113
113
necessary without affecting other fields.
114
114
115
+ .. storing followers in a list would not work well at all in case like twitter, it would grow way too large.
116
+ should only store people that user is following, and index that to get follower list of a user.
117
+ Also could use a mapping table for further flexibility in relationship.
118
+
115
119
Posts, of various types, reside in the ``social.post`` collection:
116
120
117
121
.. code-block:: javascript
@@ -250,6 +254,11 @@ Consider the following features of this schema:
250
254
certain number of comments because the :operator:`$size` query
251
255
operator does not allow inequality comparisons.
252
256
257
+ .. not sure this collection is useful, instead just use the post collection.
258
+ Posts should have an index on {user, time} and hence it is efficient to retrieve the wall.
259
+ Also wall may be scrolled down to get further items.
260
+ Dont think it's worth updating this document every time a user posts.
261
+
253
262
The second dependent collection is is ``social.news``, which collects
254
263
posts from people the user follows. These documents duplicate
255
264
information from the documents in the ``social.wall`` collection:
@@ -263,11 +272,16 @@ information from the documents in the ``social.wall`` collection:
263
272
posts: [ ... ]
264
273
}
265
274
275
+ .. This is probably too expensive.
276
+ If someone is followed by 1000+ people, that's a lot of documents to write to.
277
+ Instead system should use a $in query with people that user is following, sorted by time, with a limit.
278
+ This query is actually slow today but got improved a lot in 2.2 and there are good workarounds with 2.0.
279
+
266
280
Operations
267
281
----------
268
282
269
283
The data model presented above optimizes for read performance at the
270
- possible expense of write performance. To As a result, you should ideally
284
+ possible expense of write performance. As a result, you should ideally
271
285
provide a queueing system for processing updates which may take longer
272
286
than your desired web request latency.
273
287
0 commit comments