Cached behaviour with QSql* ?
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.
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.
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.