[Interest] how do I load massive table views instantly?
Scott Bloom
scott at towel42.com
Tue Jun 9 02:05:00 CEST 2020
One thing I have found in years past, sorting via a proxy when dealing with sql models, is a bad idea.
All models, have the "fetch" functionality. Allowing the application, to load the data incrementally.. This is critical for large tables. Yes, your scroll bars are "screwed up", but in the end, you can load very large databases, very quickly. Your limited by the SQL engine/server time to return the first 250 records, rather than the millions in the full table .
But, if you use a proxy model, the SQL model is going to have to fully load the table, then sort it. This is equivalent to selecting from the table, and sorting based on a key that isn’t indexed.
You wouldn’t want a "sorted" table to change the order as you scrolled down. Ie, if the first 250 records sorted by last name didn’t have an A in the records, and 251 did, you wouldn’t want that record to pop to the top.
A much better approach, I have used in the past, is to have the SQL model, change the select statement based on the sort column requested.
Ie, select * from table order by column_name asc
Is much faster, and a more effective method of sorting the table than select * from table, and then sorting the complete table. For small tables, honestly you might not see any difference, but for big tables the difference can be dramatic.
Scott
-----Original Message-----
From: Interest <interest-bounces at qt-project.org> On Behalf Of David M. Cotter
Sent: Monday, June 8, 2020 4:43 PM
To: interest at qt-project.org
Subject: Re: [Interest] how do I load massive table views instantly?
right okay so my source model class is QSqlRelationalTableModel, no subclass.
does this answer your question?
sorry i'm still learning about this stuff.
now that you know that, is it easier to answer my original question?
> On Jun 8, 2020, at 1:37 PM, Francis Herne <mail at flherne.uk> wrote:
>
> On Friday, 5 June 2020 17:23:37 BST David M. Cotter wrote:
>>>>> What table view are you talking about, specifically?
>>>>
>>>> QTableView with QSortFilterProxyModel
>>>
>>> What is the model _behind_ QSFPM?
>>
>> i'm trying to understand your question. i'm not sure what you mean,
>> cuz i'm not the SQLite dev what i know is that each song has a couple
>> dozen bits of data (name, artist, album, several file paths, rating,
>> duration etc etc) besides that, what are you asking?=
>
> QSortFilterProxyModel is a *proxy* that makes other models sortable.
> it only works when its `sourceModel` property is set to an instance of
> a different model class that actually contains the data.
_______________________________________________
Interest mailing list
Interest at qt-project.org
https://lists.qt-project.org/listinfo/interest
More information about the Interest
mailing list