question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Super slow comparing RealmResults

See original GitHub issue

I got some list of object from database:

newSubscribedEpisodes = realm.where(Episode.class).equalTo("isNew", true).sort("publishedDate", Sort.DESCENDING).findAll();

There is about 1100 results.

I check if those results are in the other list (about 1000 elements):

       for (Episode episode : newSubscribedEpisodes) {
            KLog.d(podcast + " " +episode + " pol");
            KLog.w(episodes.contains(episode) + " pol");
        }

And it takes about 10 seconds. But when I do a copy of the realm results list it takes 0,5s.

       realm.copyFromRealm(newSubscribedEpisodes)

It could be a walkaround but for bigger lists I get OOM for copyFromRealm().

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
nhachichacommented, Jul 10, 2018

can’t you extract only the episodes ids from RSS then use not in to discriminate episodes in Realm which are not from the RSS feed, this way you don’t have to copyFromRealm or iterate the RealmResults to do the comparison outside

Something like

String[] listOfRSSEpisodeIds = new String[]{"1", "7"};
realm.where(Episode.class)
                           .not()
                           .in("id", listOfRSSEpisodeIds)
                           .findAllAsync();
0reactions
cmelchiorcommented, Nov 28, 2018

Above solution seems to have worked. Closing

Read more comments on GitHub >

github_iconTop Results From Across the Web

Recyclerview is so slow with a lot of item - Stack Overflow
I have made this code that could retrieve from realm 50k items and show it in recyclerview: final RealmResults<AirportR> airps ...
Read more >
The things I've learned using Realm | by Gabor Varadi - Medium
I've been working on a way to expose RealmResults in an observable manner from a handler thread, either copying the dataset, mapping the...
Read more >
Realistic Realm - lessons learned after using it for 1.5 years
This can be very slow, so MVCC takes a different approach: each user connected to the database sees a snapshot of the database...
Read more >
Analysis and quantitative comparison of storage ... - DiVA Portal
databases to compare performance in CRUD operations when using a very simple ... representation of the relation between Core Data and Realm results...
Read more >
070: An honest discussion about Realm - Fragmented Podcast
You can use SQL incorrectly and make it slow. On the flip side, you can optimize the various SQL ORMs to be very...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found