Skip to content

Commit b9645e6

Browse files
agirbalSam Kleinman
authored andcommitted
review
1 parent 6cd818f commit b9645e6

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

draft/use-cases/social-networking-updates-and-profiles.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ Consider the following features of this schema:
112112
sub-document, so that you may iterate the schema can evolve as
113113
necessary without affecting other fields.
114114

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+
115119
Posts, of various types, reside in the ``social.post`` collection:
116120

117121
.. code-block:: javascript
@@ -250,6 +254,11 @@ Consider the following features of this schema:
250254
certain number of comments because the :operator:`$size` query
251255
operator does not allow inequality comparisons.
252256

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+
253262
The second dependent collection is is ``social.news``, which collects
254263
posts from people the user follows. These documents duplicate
255264
information from the documents in the ``social.wall`` collection:
@@ -263,11 +272,16 @@ information from the documents in the ``social.wall`` collection:
263272
posts: [ ... ]
264273
}
265274

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+
266280
Operations
267281
----------
268282

269283
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
271285
provide a queueing system for processing updates which may take longer
272286
than your desired web request latency.
273287

0 commit comments

Comments
 (0)