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. Cached behaviour with QSql* ?
Forum Update on Monday, May 27th 2025

Cached behaviour with QSql* ?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.4k Views
  • 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.
  • J Offline
    J Offline
    John.Doe
    wrote on 14 Nov 2011, 00:34 last edited by
    #1

    Hi,
    I've been searching to solve my problem for a while now, but never find anything.
    Background: MS SQL 2003, Qt 4.7.4, win 7 32b

    My software goal is to retrieve some production datas from the server and display them, and after doing some analysis on it in a separate part.

    Everything works fine when I was in the company. Then I start to do test abroad, on our slow connection, using a VPN. And things get really, really bad.
    While scrolling, my app becomes really, really slow. So after some wireshark analysis, I discover that my QSqlQuery is requesting for each row, at each fetch*() action. This make me look into the sourcecode to understand the process and the way the drivers works (or at least ODBC). Even if it's quite a nice behaviour most of the time, it's not suitable for my purpose, since the peoples who will use it are not connected all the time, and may be abroad quite often and so use the VPN.

    So now my question is obviously the following: Is there any way in Qt to cache the result ?
    If not, what's the good way to do it manually ? I see some undocumented QSqlCachedResult, which I try to subclass, but I have to solve this problem this week.
    Thanks

    1 Reply Last reply
    0
    • P Offline
      P Offline
      p-himik
      wrote on 14 Nov 2011, 03:53 last edited by
      #2

      Maybe "this":http://cep.xor.aps.anl.gov/software/qt4-x11-4.2.2-browser/d2/def/class_q_sql_cached_result.html will somehow help you.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        John.Doe
        wrote on 16 Nov 2011, 05:28 last edited by
        #3

        Thanks for the link.
        Finally I just dig into QODBCResult and change a little the behaviour.

        I modify QODBCResult::data(int) and QODBCResult::fetch(int) (also deleting fetchNext() and fetchPrevious(), since I won't need any forward only query).

        I add a QList<QVariant> buffer, where I store my rows when they are requested. It's almost the same behaviour as default (I cache the whole row, not only the needed columns as Qt). My app take up to 38-40 Mbs in memory for 22k rows / 55 columns of text and floats in cache. GUI seems as fluent as before with a good connection.

        I may post a suggestion on Jira later, asking for cached results. Because on a slow connection the GUI is just freezed all the time.

        1 Reply Last reply
        0

        1/3

        14 Nov 2011, 00:34

        • Login

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