Closed way1001 closed 2 years ago
The second query
realm.where(Song.class)
.sort("orderTimes")
.findAll();
will fetch all 180K elements (sorted) + you're measuring the time to copy/detach every element which shouldn't be part of the measurement (for both queries)
Using contains
in the query is very expensive as it needs to scan the whole String, would it be possible to change it to equalTo
or startsWith
?
createSnapshot
AFAIK you're not modifying the RealmResults
while iterating ?findAllAsync
as well?Hey - looks like you forgot to add a T:* label - could you please add one? :thumbsup:
@nhachicha Thanks for your detailed reply,and also know is not a performance problem. I need to query a real time rankings,so need to sort the whole records; used createSnapshot primarily for testing; query data directly for UI display, which will definitely use asynchronous. but 2 seconds of delay is slow So far i haven‘t thought of a good query
Realm version(s): 5.3.1
Realm sync feature enabled: no
Android Studio version: 3.0.0
Which Android version and device: android N, Allwinner H6
hi, every one
i have a table 180000 records ,no relationships ,not encrypted .
The query return paged show_limit = 6. it not add sort use 120ms but add sort("orderTimes") query time 2300ms
Then i changed it , query time 2100ms
How to improve speed??