Earlier quoted context omitted.
The approach I took on Diffle ( http://www.diffle.com/ - unfortunately it hasn't been exercised as we haven't really got traction yet) was to store the comment ID as a varbinary(255). A child comment takes the ID of the parent and then appends a 2-byte sequential number. So, the first comment is 0x0001, the second is 0x0002, a reply to the second is 0x00020001, a second reply is 0x00020002, the third is 0x0003, a rep…
Why not just store the parentid (can be another comment or the news topic), username (instead of userid so you don't have to access the users table), and votecount for each comment? Also, each comment should have a newsid field that points to the original newstopic. The left-most posts would have the parentid and newsid that were the same (or parentid can be zero, depending on how you do it). But any replies would ha…
PG: What's your current take on reddit's comment system?
21–30 of 67 posts
Re: PG: What's your current take on reddit's comment system?
#22Re: PG: What's your current take on reddit's comment system?
#23Earlier quoted context omitted.
Why not just store the parentid (can be another comment or the news topic), username (instead of userid so you don't have to access the users table), and votecount for each comment? Also, each comment should have a newsid field that points to the original newstopic. The left-most posts would have the parentid and newsid that were the same (or parentid can be zero, depending on how you do it). But any replies would ha…
How do you get the full thread for a given parent? Selecting based on the parentid alone gives you only immediate descendants. Recursive queries are generally a no-no, as they drag your performance down fairly quickly. Selecting based on the newsid gives you every single comment on the item, and then you'll have to do a lot of work (basically building up the full tree structure in memory) to find out which are childr…
To simplify the recursive function (using data in memory, not in the database), you could also have another field, called indent, that stores the level in the comments.
You could find all the comments with one SQL statement (where newsid = news.id), then go through each level of each comment, and sort it that way.
You could even make the parentid field a double, so you would store 123.4 where 123 would be the parent and 4 would be the indentation level.
I guess the difference is, do you want to store everything in one field or have different fields for everything?
I think this gives the original poster many options to think about. To me, a recursive function would be easier to write than coming up with ways to combine multiple fields into one using MySQL.
I think the order of optimization is: 1) Optimize so you can use a cached result if it exists 2) If the cache is out of the date, try to make just one SQL call 3) don't use table joins 4) reorder the data as needed in memory, then save it to a cache
As far as the single SQL call goes, I don't think it matters whether you have 5 fields or 30 in the actual table as long as you only request the fields you need, but I could be wrong.
By the way, do you have any other interesting examples?
Re: PG: What's your current take on reddit's comment system?
#24Earlier quoted context omitted.
How do you get the full thread for a given parent? Selecting based on the parentid alone gives you only immediate descendants. Recursive queries are generally a no-no, as they drag your performance down fairly quickly. Selecting based on the newsid gives you every single comment on the item, and then you'll have to do a lot of work (basically building up the full tree structure in memory) to find out which are childr…
You would find the full thread by searching for comments with the appropriate newsid. To simplify the recursive function (using data in memory, not in the database), you could also have another field, called indent, that stores the level in the comments. You could find all the comments with one SQL statement (where newsid = news.id), then go through each level of each comment, and sort it that way. You could even mak…
Re: PG: What's your current take on reddit's comment system?
#25It actually sucks me into the troll MORE when they get such special highlighting. I should say I do like how top level troll posts get put at the bottom for reddit.
Re: PG: What's your current take on reddit's comment system?
#26Re: PG: What's your current take on reddit's comment system?
#27While reddit's comment system is obviously an improvement over Slashdot's, I'm increasingly convinced that community makeup is far more important than the tool it uses.
I agree, basically. Except I think customs are as important as or more important than makeup. That's why I try to discourage ad hominems. To be fair to the reddits, it wasn't their fault that the discussion on reddit sank down toward that of digg and slashdot. They have really strong beliefs against censorship. They were never going to jump into a discussion and tell people to stop being jerks. But empirically it loo…
Re: PG: What's your current take on reddit's comment system?
#28On the topic of community makeup, here are some interesting findings that come from Yahoo's social scientists (using Yahoo lists as the dataset): 1) Small groups have higher numbers of core users 2) Private and semi-public groups have higher numbers of core users than public groups 3) People in private groups remain in the core for longer 4) A user who is in the core of one group is more likely to become a member of…
You can email me if you like.
Re: PG: What's your current take on reddit's comment system?
#29Earlier quoted context omitted.
If you're trying to mimic this forum with a database solution, it's going to be a pain. PG's keeping this stuff in memory, almost certainly as the tree that it is. edit on the edit: scratch that.
I mentioned a possible solution here: http://news.ycombinator.com/item?id=33902 , but I'm really commenting because there's a really cool connection between PG's approach of storing it as an in-memory tree and my approach of a 2048-bit index: Y'know how in a typical CS datastructures course you'll have to build a heap, and then reimplement with an array? A heap is conceptually a balanced binary tree where every leaf…
Edit: See Ruby/Lisp for one such already built interpreter.
Re: PG: What's your current take on reddit's comment system?
#30On the topic of community makeup, here are some interesting findings that come from Yahoo's social scientists (using Yahoo lists as the dataset): 1) Small groups have higher numbers of core users 2) Private and semi-public groups have higher numbers of core users than public groups 3) People in private groups remain in the core for longer 4) A user who is in the core of one group is more likely to become a member of…
Alex, this is very interesting. Do you think there might be a way to get one's hands on the original? If there is a person/persons at Yahoo to contact I would do it, as this is something I have thought about quite a bit and would love to see more about the definitions of core, light, new, long-time, large and small. You can email me if you like.
I've developed this hobby of sneaking into academic conferences. It works best if when everyone else is wearing a suit and tie, you show up in shorts and a t-shirt. That way everyone just assumes that you're friends with one of the speakers, or else that you're Sergei Brin. :-)