realm / realm-js

Realm is a mobile database: an alternative to SQLite & key-value stores
https://realm.io
Apache License 2.0
5.74k stars 565 forks source link

Slow first read big data in realms #2458

Open shamkhalshukurov opened 5 years ago

shamkhalshukurov commented 5 years ago

I have created chat application in real native app . Messages screen wait for long time (2-3 second) when quering big data (40000-50000 rows) 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);

I use { type: 'string', indexed: true } for dialogue_id and unixtime in Messages schema. Realmjs version 3.0.0-beta.1

realm-probot[bot] commented 5 years ago

Hey - looks like you forgot to add a T:* label - could you please add one?

realm-probot[bot] commented 5 years ago

Hey - looks like you forgot to add a T:* label - could you please add one?

kneth commented 5 years ago

@shamkhalshukurov If you only want to see the first 50 objects, LIMIT 50 might help you.

shamkhalshukurov commented 4 years ago

Thanks for answer. Query is remarkable rapid when I remove SORT from query. Although I have added LIMIT(50) to query , here is not remarkable difference with SORT . It freezes JS thread for 1000-1500 ms. How I can perform queries Asynchronously ? .

kneth commented 4 years ago

Currently Realm JS doesn't support an async query mechanism. It is a not trivial feature to implement but I can see the value in it.