Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. what to do when your select query consist so many rows at a time ? How to reduce its impact on heap memory ?

what to do when your select query consist so many rows at a time ? How to reduce its impact on heap memory ?

Scheduled Pinned Locked Moved Unsolved C++ Gurus
7 Posts 4 Posters 1.0k 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.
  • Q Offline
    Q Offline
    Qt embedded developer
    wrote on last edited by
    #1

    i am executing select query with SQLITE3_EXEC function for 2104 records that contain multiple fields. this query execution take too much utilization of heap memory.

    i don't know How to free heap or how to reduce the use of it ?

    artwawA JonBJ 2 Replies Last reply
    0
    • Q Qt embedded developer

      i am executing select query with SQLITE3_EXEC function for 2104 records that contain multiple fields. this query execution take too much utilization of heap memory.

      i don't know How to free heap or how to reduce the use of it ?

      artwawA Offline
      artwawA Offline
      artwaw
      wrote on last edited by artwaw
      #2

      @Qt-embedded-developer how is that qt related? please show your code.

      Edit: from the top of my head though, quick fix (but might not be applicable to your situation) is to include "limit" clause in your query and process the data in the loop, in batches resulting from the said limit.

      For more information please re-read.

      Kind Regards,
      Artur

      Q 1 Reply Last reply
      1
      • artwawA artwaw

        @Qt-embedded-developer how is that qt related? please show your code.

        Edit: from the top of my head though, quick fix (but might not be applicable to your situation) is to include "limit" clause in your query and process the data in the loop, in batches resulting from the said limit.

        Q Offline
        Q Offline
        Qt embedded developer
        wrote on last edited by
        #3

        @artwaw will it free my heap_max memory ?

        jsulmJ 1 Reply Last reply
        0
        • Q Qt embedded developer

          @artwaw will it free my heap_max memory ?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Qt-embedded-developer SQL LIMIT clause is not a memory manager.
          Please read https://www.w3schools.com/sql/sql_top.asp

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          artwawA 1 Reply Last reply
          0
          • jsulmJ jsulm

            @Qt-embedded-developer SQL LIMIT clause is not a memory manager.
            Please read https://www.w3schools.com/sql/sql_top.asp

            artwawA Offline
            artwawA Offline
            artwaw
            wrote on last edited by
            #5

            @jsulm that was my suggestion. My thinking is that limiting the amount of returned data might preserve some memory, no? (depending on how the results are cached, of course, we don't know exactly how OP is handling the queries)

            For more information please re-read.

            Kind Regards,
            Artur

            jsulmJ 1 Reply Last reply
            0
            • artwawA artwaw

              @jsulm that was my suggestion. My thinking is that limiting the amount of returned data might preserve some memory, no? (depending on how the results are cached, of course, we don't know exactly how OP is handling the queries)

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @artwaw said in what to do when your select query consist so many rows at a time ? How to reduce its impact on heap memory ?:

              My thinking is that limiting the amount of returned data might preserve some memory, no?

              Yes, of course. It reduces the amount of used memory, but it does not "free" memory, like freeing after using it.
              I replied to "will it free my heap_max memory ?".

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              3
              • Q Qt embedded developer

                i am executing select query with SQLITE3_EXEC function for 2104 records that contain multiple fields. this query execution take too much utilization of heap memory.

                i don't know How to free heap or how to reduce the use of it ?

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

                @Qt-embedded-developer
                Apart from the suggestions for limiting rows returned, make sure you only request those columns you really need.

                I don't know whether the option has any effect when using SQLite, but do try setting QSqlQuery::setForwardOnly(bool forward). It could make a big difference to memory usage (and speed).

                1 Reply Last reply
                3

                • Login

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