Ask HN: What is the Hacker News database structure? Does it use tables or NoSQL?
HN always seems pretty fast and is probably well designed from a data structure standpoint.
It seems that each comment and submissions are assigned a monotonically increasing number; do both submissions and comments share the same numeric space?
How is the content hierarchy stored? Is it a single large table with (for example) a structure that looks like id, parentID, contenttype, content?
Is data stored in an OLAP SQL database, on disk as flat files, in DBM files, etc?
What kind of performance is required? Is the database distributed across more than one machine?
5 comments
[ 3.3 ms ] story [ 26.2 ms ] threadhttps://github.com/wting/hackernews/blob/5a3296417d23d1ecc90... shows the monotonically increasing number:
It's used for stories: and comments: No clue how that code structure compares to current implementation. For all I know it's completely different.Is each HN thread it’s own file? How do we add additional posts into the discussion, maintaining the hierarchy? If each file is a thread, then adding to the discussion means we deserialize the file into memory into some data structure and perform updates in memory? Or is there some syntax that allows us to append to a specific blob/container in the file?
Another way could be maybe you have a file and folder per HN thread, and each response and it’s own responses are their own folder and files (recursively). Not sure how performant this would be though.