[Qt-interest] QSql(Query|Table)Model without caching possible?

Davor J. DavorJ at live.com
Fri Feb 26 09:14:08 CET 2010


Thanks for the informative links André. I haven't been able to research the 
issue fully. Speed in my project isn't really the priority momentarily, but 
it might become in the future.

Still, I think I have found the culprit: QSqlQuery. Bot the Sql models use 
it for access of the database data. It seems also to be the place where all 
the caching happens. For example, if you do "QSqlQuery q("SELECT * FROM 
test01", some connection);" on a large table, then it will apparently fetch 
all the data before it becomes available for future use.

So this made me think that if I could subclass QSqlResult, implement some 
virtual functions such as the virtual fetch functions, use QSqlQuery as a 
wrapper for it, and then use that with QSqlQueryModel, I might actually make 
a non-caching model (?).

Kind regards,
Davor

(PS In the meantime I have also found some workarounds with threading, but 
it doesn't really seem to be a solution for very large tables. But then 
again, I might change my mind.)


"Andre Somers" <andre at familiesomers.nl> wrote in message 
news:4B86623B.4070508 at familiesomers.nl...
> Davor J. wrote:
>> Thanks Andre. It's an interesting suggestions which I have overlooked. 
>> But it's not the case.
>>
>> Even if I set up the model without the view:
>> -----------------------------------------------------------
>>     QSqlTableModel m(0 /*, dbConnction*/);
>>     m.setTable("test01");
>>     m.select();
>> -----------------------------------------------------------
>> ... the application freezes and the network connection peaks for some 10 
>> seconds. So there is no difference whether there is a view or not.
>>
>> (I know... this could be solved with threading or allowing the app events 
>> to pass, but then it also goes beyond my initial question. I don not need 
>> to cache all the data if I only need a few.)
>>
>> Regards,
>> Davor
>>
> OK, so that's one obvious suspect out of the way :-)
> I know there has been some discussion on similar (the same?) issues quite 
> recently on this list. Perhaps that discussion, which started on februari 
> 1 this year and is called "Model/View delayed loading for large datasets" 
> gives you some useful hints. However, I also understand that QSql*Model 
> should do some of this stuff internally already. I have never used it 
> myself in this way, so I don't have much detail on that. Sorry. Perhaps 
> the sources can enlighten you there?
>
> André 





More information about the Qt-interest-old mailing list