2

React native app freezes when querying big data from realm database.

let list = realm.objects('Messages');
list = list.filtered('dialogue_id = $0 SORT(unixtime ASC)', dialogue_id);
I use
list = list.slice(0, 50);

Realmjs version 3.0.0-beta.1

Response time is 3s.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

0

Your problem here is calling list.slice(0, 50), it is very slow to pull data out of Realm into JS objects. You're better off leaving them in the Realm collection and reading directly from the Realm.Object and updating values using Realm writes. You should limit your results in your query as shown list = list.filtered('dialogue_id = $0 SORT(unixtime ASC) LIMIT(50)', dialogue_id); and using the Realm collection directly without instantiating JS objects from the results.

Mish
  • 145
  • 5