Live data from Hacker News

There's no single best way to store information

quantamagazine.org

21–30 of 53 posts

Re: There's no single best way to store information

#21
post #11

The best way to store information depends on how you intend to use (query) it. The query itself represents information. If you can anticipate 100% of the ways in which you intend to query the information (no surprises), I'd argue there might be an ideal way to store it.

This line of thought works for storage in isolation, but does not hold up if write speed is a concern.

Re: There's no single best way to store information

#22
This clicked for me in a way I didn't expect.

I've been thinking about trade-offs as "pick two of three" in the abstract, but the bookshelf example made it concrete. The insight that matters is: if you know your query patterns, you can optimize differently.

As a PM, I keep trying to build systems that work for "every case." But this article reminded me that's the wrong goal. The hash table works because it accepts the space-time trade-off. The heap works because it embraces disorder for non-priority items.

Sometimes the best system isn't the most elegant one—it's the one that matches how you'll actually use it.

Good reminder to stop over-optimizing for flexibility I'll never need.

Thanks for sharing.

Re: There's no single best way to store information

#23

There are, however, several objectively bad ways. In "Service Model" (a novel that I recommend) a certain collection of fools decides to sort bits by whether it's a 1 or a 0, ending up with a long list of 0's followed by a long list of 1's.

That's fine so long as there's an index!

Re: There's no single best way to store information

#24
post #8

There are, however, several objectively bad ways. In "Service Model" (a novel that I recommend) a certain collection of fools decides to sort bits by whether it's a 1 or a 0, ending up with a long list of 0's followed by a long list of 1's.

It _does_ open up amazing opportunities for compression though.

[deleted]

Re: There's no single best way to store information

#26
post #11

The best way to store information depends on how you intend to use (query) it. The query itself represents information. If you can anticipate 100% of the ways in which you intend to query the information (no surprises), I'd argue there might be an ideal way to store it.

This line of thought works for storage in isolation, but does not hold up if write speed is a concern.

as a line of thought, it totally does. you just extend the workload description to include writes. where this get problematic is that the ideal structure for transactional writes is nearly pessimal from a read standpoint. which is why we seem to end up doubling the write overhead - once to remember and once to optimize. or highly write-centric approach like LSM

I'd love to be clued in on more interesting architectures that either attempt to optimize both or provide a more continuous tuning knob between them

Re: There's no single best way to store information

#27
post #19
post #16

There are plenty of good enough ways: * For lossless compression of generic data, gzip or zstd. * For text, documentation, and information without fancy formatting, markdown, which is effectively a plain-text superset. * For small datasets, blobs, objects, and what not, JSON. * For larger datasets and durable storage, SQLite3. Whenever there's text involved, use UTF-8. Whenever there's dates, use ISO8601 format (UTC…

One format I'm missing: storage for conversations and social media posts. Both are complex media (text + images/videos + metadata), and one is actually a collection of such posts. How would you go about storing those in a somewhat human-readable format? My goal is to archive my chats and social media activity.

Why not just use WARC and a program that can read them? Do archives need to be human-readable?

Re: There's no single best way to store information

#28
post #19
post #16

There are plenty of good enough ways: * For lossless compression of generic data, gzip or zstd. * For text, documentation, and information without fancy formatting, markdown, which is effectively a plain-text superset. * For small datasets, blobs, objects, and what not, JSON. * For larger datasets and durable storage, SQLite3. Whenever there's text involved, use UTF-8. Whenever there's dates, use ISO8601 format (UTC…

One format I'm missing: storage for conversations and social media posts. Both are complex media (text + images/videos + metadata), and one is actually a collection of such posts. How would you go about storing those in a somewhat human-readable format? My goal is to archive my chats and social media activity.

Use a SQLite3 database. Have a table for the posts (or any other appropriate schema, depending on what metadata you have). Using SQLite3 has the advantage of future flexibility (new/different tables and schema as needed, full-text search, etc.).

You can have another table for attachments (images, videos, etc.). If they're small, store them directly in a BLOB. If they're not, store them alongside the database, and only store the relative path in the attachments table.

You may opt to convert images and videos to a single format (e.g. PNG and H.264 MP4), but you can lose information depending on the target format. It may be preferable to leave them in the original (or highest quality) format.

Re: There's no single best way to store information

#29
post #19

Earlier quoted context omitted.

One format I'm missing: storage for conversations and social media posts. Both are complex media (text + images/videos + metadata), and one is actually a collection of such posts. How would you go about storing those in a somewhat human-readable format? My goal is to archive my chats and social media activity.

Why not just use WARC and a program that can read them? Do archives need to be human-readable?

The thing about archives is you either parse them now or parse them later. With how much JS and other crap is served in modern social media frontends, I'm not sure WARC is the best format for archiving from them.

Re: There's no single best way to store information

#30

Or it's the opposite, where the slowest possible retrieval time is the intended effect, as is the basis of many cryptographic algorithms.

Or it's neither, and the intended effect is zero variation in the retrieval time, as when trying to avoid leaking secrets via timing attacks.

(Or I guess, more generally, the intended effect is zero correlation between the information and the time it takes to retrieve it. If retrieval time were completely random, it would achieve the goal, but it wouldn't have zero variation.)

Post reply on HN