while investigating on slow response time, I tracked down the issue to this code section
the first 2 log messagest ("query start" and "query end") are printed in less than a second, while the "add record" lines come rather slowly, about 1 sec apart one another
the whole While loop ends in about 20 seconds, with no noticeable difference between Debug and Release mode
the query returns 21 records from a table (actually a view) with 300000 lines
the same query, when performed in "DB Browser for SQLite" takes about 900ms
from the elapsed time, it looks like every NextRecord call just performs the whole query again
i already run ANALYZE and PRAGMA optimize on the DB with no effect
am i missing something?
B4X:
Dim entries As List
entries.Initialize
WriteLog("query start")
Dim rs As ResultSet = DB.ExecQuery2("SELECT DISTINCT carvaluename FROM carvalues WHERE timestamp>=? AND timestamp<=? ORDER BY carvaluename", Array As String(starttimestamp, endtimestamp))
WriteLog("query end")
Do While rs.NextRow
WriteLog("add record")
entries.Add(rs.GetString("carvaluename"))
Loop
rs.Close
the first 2 log messagest ("query start" and "query end") are printed in less than a second, while the "add record" lines come rather slowly, about 1 sec apart one another
the whole While loop ends in about 20 seconds, with no noticeable difference between Debug and Release mode
the query returns 21 records from a table (actually a view) with 300000 lines
the same query, when performed in "DB Browser for SQLite" takes about 900ms
from the elapsed time, it looks like every NextRecord call just performs the whole query again
i already run ANALYZE and PRAGMA optimize on the DB with no effect
am i missing something?