• nous@programming.dev
    link
    fedilink
    English
    arrow-up
    5
    ·
    15 hours ago

    What is wrong with a file for this? Sounds more like a local log or debug output that a single thread in a single process would be creating. A file is fine for high volume append only data like this. The only big issue is the format of that data.

    What benefit would a database bring here?

    • NeatNit@discuss.tchncs.de
      link
      fedilink
      arrow-up
      14
      ·
      15 hours ago

      I think SQLite is a great middle ground. It saves the database as a single .db file, and can do everything an SQL database can do. Querying for data is a lot more flexible and a lot faster. The tools for manipulating the data in any way you want are very good and very robust.

      However, I’m not sure how it would affect file size. It might be smaller because JSON/YAML wastes a lot of characters on redundant information (field names) and storing numbers as text, which the database would store as binary data in a defined structure. On the other hand, extra space is used to make common SQL operations happen much faster using fancy data structures. I don’t know which effect is greater so file size could be bigger or smaller.

      • Scrath@lemmy.dbzer0.com
        link
        fedilink
        arrow-up
        4
        ·
        12 hours ago

        I didn’t look to much at the data but I think csv might actually be an appropriate format for this?

        Nice simple plaintext and very easy to parse into a datastructure for analysing/using it in python or similar

    • towerful@programming.dev
      link
      fedilink
      arrow-up
      11
      ·
      15 hours ago

      Smaller file size, lower data rate, less computational overhead, no conversion loss.

      A 64 bit float requires 64 bits to store.
      ASCII representation of a 64 bit float (in the example above) is 21 characters or 168 bits.
      Also, if every record is the same then there is a huge overhead for storing the name of each value. Plus the extra spaces, commas and braces.
      So, you are at least doubling the file size and data throughput. And there is precision loss when converting float-string-float. Plus the computational overhead of doing those conversions.

      Something like sqlite is lightweight, fast and will store the native data types.
      It is widely supported, and allows for easy querying of the data.
      Also makes it easy for 3rd party programs to interact with the data.

      If you are ever thinking of implementing some sort of data storage in files, consider sqlite first.

    • qaz@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      5
      ·
      edit-2
      15 hours ago

      It’s used to export tracking data to analyze later on. Something like SQLite seems like a much better choice to me.

    • Azzu@lemmy.dbzer0.com
      link
      fedilink
      arrow-up
      3
      ·
      15 hours ago

      Because this is not log or debug data as OP said. In any case, what do you think would happen with this data? It will be analyzed by some sort of tool because no one could manually look at this much text data. In text, this can be like 1MB of data per second. So in a normal eye tracking session, probably hundreds of MB. The problem isn’t the storage space, but the time it will take to read that in and analyze it each time, forcing you to wait for processing or use lots of memory while reading it. And anyway, in most languages, it’s actually much easier to store the number values directly (in 8 bytes not the 30something this text representation uses) than to convert them to JSON, all languages have some built-in way to do that. And even if not, sqlite is piss-easy and does everything for you, being as simple as JSON.

      There is just no reason to do it like that unless you just don’t think about what you’re doing or have no clue.