View Full Version : QSqlQueryModel tweaks?
baray98
18th July 2009, 04:05
I have an SQL stement that will return millions of record ie
select * from myTable
i noticed that this will take sometime to see it on my QTableView. now my question is . Where can i possibly tweak it to make it faster?
My opinion:
I think QSqlQueryModel is caching just 256 records at a time , and model to view will take no time at all. I think its really the database that is taking the time to "build" those records for me. If theres in any other path that i can work on to make it a bit faster please enlighten me...
by the way my database is MS SQL
baray98
wysota
18th July 2009, 09:06
Use QSqlTableModel, there is a chance it will be faster. If not then you can't use such a simple model and need to ask the database for just part of the data at a time. Also have a look at this: http://blog.wysota.eu.org/index.php/2006/12/26/remote-models/
baray98
21st July 2009, 08:03
wysota,
may i know why you think QSqlTableModel would be faster than QSqlQueryModel if you don't mind.
baray98
wysota
21st July 2009, 09:10
As far as I remember the query model downloads all rows from the query result at once and the table model fetches rows as they are needed but I may be wrong.
ChrisW67
22nd July 2009, 00:17
I found the same behaviour with QSqlTableModel (which is built atop QSqlQueryModel anyway) on Sqlite databases. The QTableView displays the first 255 (model's QSQL_PREFETCH value) rows and scales its vertical scroll bar for that number (the model is returning a rowCount()==255). When you drag the scroller down you get a long pause as the model fetches another 255 rows and rescales the scroll bar. It will keep doing this until all rows are fetched. The only way I found to have smooth end-to-end scrolling was to do:
while (model->canFetchMore()) model->fetchMore(); which is acceptable for a few thousand rows but not (probably) a few million.
baray98
22nd September 2009, 00:58
I visited your blog http://blog.wysota.eu.org/index.php/...remote-models/ and tried your remotemodel and I think its a cool idea for my case and you mentioned you've tried it in some SQL database too.
If its not too much I am wondering if you can share a snippet of your model accessing SQL database so I can test if it will improve my problem.
baray98
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.