• 1 Post
  • 12 Comments
Joined 8 months ago
cake
Cake day: October 23rd, 2023

help-circle





  • Yep — that is what I mean by documents, and it’s what I meant all along. The beauty of documents is how simple and flexible they are. Here’s a URL (or path), and here’s the contents of that URL. Done.

    But that content is meaningless, because you just saved an arbitrary data structure. It’s not as if you can do anything with those postgres files. Or those possibly multi GB MSSQL .mdf, .ldf, .ndf documents. That’s data (a word that’s imo far clearer than document) stored in a very specific way that you need to know the exact structure of to make any sense of. It’s not usable directly in any way. Not “Done.”

    No, because you can’t store “literally anything” in a Postgres database.

    Yes you can. You can either add space for what you need to store, or you can, again, store e.g. a JSON blob.

    if you put an index on this column, inserts will be too slow, if you don’t have an index on that column selects will be too slow

    Or don’t, and it will only be as slow ass a NoSQL Database …

    A document is always more work in the short term

    It’s the opposite, a document db is far easier in the short term, that’s why everyone jumped on them before seeing the limitations.

    Yeah, a relational DB is harder because you have to have a good design, that allows you to do what you actually want to do. And if you none of your devs are good at SQL, then probably a document db is better. And yes, sometimes, you need nothing but a document DB. But I still heavily disagree that most of the time you want one.


  • I’m 99% certain this is wrong

    ? This is how Postgres stores data, as documents, on the local filesystem:

    Those are not documents for a definition of document that works with the rest of your comment. If by document you mean “any kind of data structure”, then yes, those are documents. But then the term becomes meaningless, as literally anything is a document.

    Yep… it’s pretty easy to write a query on a moderately large database that returns 1kb of data and takes five minutes to execute. You won’t have that issue if your 1kb is a simple file on disk. It’ll read in a millisecond.

    Sure, but then finding that document takes 5 minutes because you need to read a few million files first.



  • and it’s even how relational databases work under the hood. They generally persist data on the filesystem as documents.

    I’m 99% certain this is wrong, which leads to a lot of your follow-up being wrong. Persisting data as documents would be atrocious for performance.

    I also disagree with the quoted part of the article.

    And for your case, sure, you could save it as document, maybe improve performance of a very light operation by 2X, just to have far worse performance for querying that data.

    edit: And in case you don’t mind the extra storage, and don’t care about correctness guarantees, you can just have a table that has all the metadata, but then have the comment also as a JSON blob which every modern db supports.