The trick is to have a way to identify the first/current row and use that in 
the WHERE clause.

e.g. SELECT ... FROM customers WHERE customer_id >= last_displayed LIMIT 
window_size

If your select statement is a complex join without any usable key, you will 
have to resort to storing the results

    CREATE TEMP TABLE select_results AS SELECT ...

And displaying only those within the current window

    SELECT * FROM select_results WHERE rowid >= starting_line LIMIT window_size;


As an optimization, you can populate the temporary table in the background 
while displaying the first page of results.

-----Ursprüngliche Nachricht-----
Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im 
Auftrag von Thomas Flemming
Gesendet: Mittwoch, 24. Mai 2017 10:09
An: sqlite-users@mailinglists.sqlite.org
Betreff: [sqlite] SQLite3.Step fast forward / skipping rows

Hi SQLite Users,


I have a SELECT query, which returns some 100000 records and is displayed in a 
scrollable ListView.

When the user scrolls down the list, each new row is loaded with SQLite3.Step().

The problem is, when the user scrolls fast with the scroll-slider, lots of rows 
are skipped, but SQLite still needs to load them all with SQLite3.Step until it 
reaches the row which is actually needed. This is very slow.

Is there a way to skip all these unnecessary rows? For example going directly 
from row 1000 to row 100000 ? I tried SELECT ... OFFSET 100000 but this is also 
very slow the more down we go.

Thanks
Tom


--
/****************************************
**   Flemming Software Development CC
**   Thomas Flemming
**   PO Box 81244
**   Windhoek, Namibia
**   http://www.quovadis-gps.com
**   mail  t...@qvgps.com
**   +264 (0)81 3329923
**   +49  (0)6182 8492599
***************************************/
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


___________________________________________
 Gunter Hick
Software Engineer
Scientific Games International GmbH
FN 157284 a, HG Wien
Klitschgasse 2-4, A-1130 Vienna, Austria
Tel: +43 1 80100 0
E-Mail: h...@scigames.at

This communication (including any attachments) is intended for the use of the 
intended recipient(s) only and may contain information that is confidential, 
privileged or legally protected. Any unauthorized use or dissemination of this 
communication is strictly prohibited. If you have received this communication 
in error, please immediately notify the sender by return e-mail message and 
delete all copies of the original communication. Thank you for your cooperation.


_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to