Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Best(fastest) way to save and load 150MB of data
Qt 6.11 is out! See what's new in the release blog

Best(fastest) way to save and load 150MB of data

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 4 Posters 3.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • cpperC Offline
    cpperC Offline
    cpper
    wrote on last edited by
    #1

    Currently, my app downloads data from the internet on each run (about 100-200 MB). The data is a list of timestamp - value pairs (imagine QList<QMap<double,double>>). In order to speed up the initialization of the app, I decided to save the downloaded data locally on the first run, and on subsequent runs load the saved data, and download only new data from the internet.
    Obviously, I only care about sequentially reading the saved data on each startup of the app, and then sequentially appending a bit of new data.

    The easiest option to save the data is plain text files (using QFile). Should I consider another method of storing the data ? Maybe JSON, some form of archiving, or even SQL ? What is the fastest method of loading the data (considering its size and the sequential access) ?

    JonBJ 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      It really depends on your usecase what you want to do with your data.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • sierdzioS Offline
        sierdzioS Offline
        sierdzio
        Moderators
        wrote on last edited by
        #3

        Based on the description I'd say the best solution is to use a database. With a DB you won't need to worry about details of implementation, SQL will take care of it. It will also be easy to search through the records if needed, sort them etc.

        (Z(:^

        1 Reply Last reply
        0
        • cpperC cpper

          Currently, my app downloads data from the internet on each run (about 100-200 MB). The data is a list of timestamp - value pairs (imagine QList<QMap<double,double>>). In order to speed up the initialization of the app, I decided to save the downloaded data locally on the first run, and on subsequent runs load the saved data, and download only new data from the internet.
          Obviously, I only care about sequentially reading the saved data on each startup of the app, and then sequentially appending a bit of new data.

          The easiest option to save the data is plain text files (using QFile). Should I consider another method of storing the data ? Maybe JSON, some form of archiving, or even SQL ? What is the fastest method of loading the data (considering its size and the sequential access) ?

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @cpper
          I do not share @sierdzio's thought that storing what was a bunch of thousands(?) of consecutive records which you say you wanted in memory or for sequential access is best stored in a database/file which then has to be searched. IMHO in-memory manipulation is a lot faster than any file-based. But it does depend totally on your use case.

          From the way you described, my initial thought was to use QDataStream of the binary representation (e.g. QList<QMap<double,double>>)), which I assume to be "fast" on read/write, and no need to convert to/from text. But I don't know whether a QDataStream file allows any kind of "append new items" --- it may not. I'd be interested if anyone knows about this?

          Otherwise the "fastest" is surely just a sequential layout of the records, which is just (approximately?) a sequence of double,doubles, easy to save, load, and reconstruct the maps.

          1 Reply Last reply
          2
          • sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #5

            SQLite supports in-memory storage link but yes @JonB you raise some good points here.

            (Z(:^

            JonBJ 1 Reply Last reply
            2
            • sierdzioS sierdzio

              SQLite supports in-memory storage link but yes @JonB you raise some good points here.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @sierdzio said in Best(fastest) way to save and load 150MB of data:

              SQLite supports in-memory storage

              Point taken. You probably know more than I do [which the OP should bear in mind!]. And I admit I haven't used SQLite and have a natural antipathy toward any database solution unless I see a database need. Which may be wrong of me. But my thought is that, even in-memory, there must be some huge overhead in storing/processing as database records what is apparently supposed to be just 150MB-worth of sequential doubles?

              1 Reply Last reply
              0
              • sierdzioS Offline
                sierdzioS Offline
                sierdzio
                Moderators
                wrote on last edited by
                #7

                I don't know, to be honest - it would be interesting to benchmark it out. Databases tend to be pretty well optimized. But I suggested using a DB not necessarily for speed, but rather for convenience - it should be easier to synchronize local and remote data with a database which does a lot of heavy lifting (checking uniqueness, searching etc.) automatically.

                (Z(:^

                JonBJ 1 Reply Last reply
                1
                • sierdzioS sierdzio

                  I don't know, to be honest - it would be interesting to benchmark it out. Databases tend to be pretty well optimized. But I suggested using a DB not necessarily for speed, but rather for convenience - it should be easier to synchronize local and remote data with a database which does a lot of heavy lifting (checking uniqueness, searching etc.) automatically.

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by
                  #8

                  @sierdzio
                  Agreed, but I am trying to answer the OP's "Best(fastest) way to save and load 150MB of data".

                  1 Reply Last reply
                  1
                  • cpperC Offline
                    cpperC Offline
                    cpper
                    wrote on last edited by
                    #9

                    Thanks for the answers. Here more detail about the data:

                    The downloaded and saved data is historic cryptocurrency price data, for multiple pairs (like BTC-USD, ETH-USD ...). I do some basic math with this data (like calculating % change) and plot it in QCharts. I'm more interested in the fastest way to load the data, since saving the biggest chunk takes place only once, at the first run of the app. On subsequent runs, only a small amount of new price data will be saved to the local data. Also, I don't care about things like searching or sorting the data.

                    JonBJ 1 Reply Last reply
                    0
                    • Christian EhrlicherC Offline
                      Christian EhrlicherC Offline
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Then use a simple plain QFile

                      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                      Visit the Qt Academy at https://academy.qt.io/catalog

                      1 Reply Last reply
                      0
                      • cpperC cpper

                        Thanks for the answers. Here more detail about the data:

                        The downloaded and saved data is historic cryptocurrency price data, for multiple pairs (like BTC-USD, ETH-USD ...). I do some basic math with this data (like calculating % change) and plot it in QCharts. I'm more interested in the fastest way to load the data, since saving the biggest chunk takes place only once, at the first run of the app. On subsequent runs, only a small amount of new price data will be saved to the local data. Also, I don't care about things like searching or sorting the data.

                        JonBJ Offline
                        JonBJ Offline
                        JonB
                        wrote on last edited by
                        #11

                        @cpper said in Best(fastest) way to save and load 150MB of data:

                        and plot it in QCharts

                        Others may well know about QCharts but I'm afraid I don't. But if you are looking at the "fastest" way of accessing this data, my first question would be how do you present this data to QtCharts for the plotting? Is there a model? An in-memory or database one? Does it have to be a QList<QMap<double,double>>) or something? One would assume the fastest would be however one can most quickly stuff the data from disk into the structure directly required for the plotting.

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved