Previous query joined the whole of _points to _devices before filtering. That one took between 10 and 16 seconds for me. (2.5m points in an SQLite database) This caused OwnTracks to fail to log in the background most of the time.
Moved the JOIN to the outer query which reduced the time to 3 seconds.
While this will now first find the latest points for ALL devices and filter them afterwards for the specified sessionid, it works a lot faster for me because it can make use of the indexes.
Previous query joined the whole of _points to _devices before filtering. That one took between 10 and 16 seconds for me. (2.5m points in an SQLite database) This caused OwnTracks to fail to log in the background most of the time.
Moved the JOIN to the outer query which reduced the time to 3 seconds.
While this will now first find the latest points for ALL devices and filter them afterwards for the specified
sessionid
, it works a lot faster for me because it can make use of the indexes.