I'm seeing very slow query performance on an array with only around ~30k objects. Even just 10 recent records are taking close to 30 seconds to query which makes me suspect that it isn't hitting an index(not sure how to tell if this is the case).
{
"rules": {
"users": {
"$uid": {
".read": "$uid === auth.uid",
".write": "$uid === auth.uid",
"timeseries": {
".indexOn": ["timestamp"]
}
}
}
}
}
schema is:
app/user/$uid/timeseries/$id/timestamp (see attached)
I'm querying like so:
var getRealtimeData = function(lastSeconds=60){
var uid=auth.$getAuth().uid;
var ref =firebase.database().ref("/users/" + uid + "/timeseries");
var start = Date.now() - (lastSeconds*1000);
ref=ref.orderByChild("timestamp").startAt(start);
return $firebaseArray(ref);
}
Am I hitting the index? What query times should I expect? What if my array had 1M or 10M items? I can think of a few ways to optimize i.e by pre-aggregating the data so I have fewer objects or bucketing it by day in separate paths but I'd like to make sure i'm at least getting expected performance.
Thanks,
David