Slowdown in Retrieving tags from firebase in Real-time

the latest timestamp and its fields

A setup like this should return the last reading/timestamp/data

in your firebase rules:

in your blocks, use a web component to query the data:

1 Like

Here is how to show the newly arrived data for a single timestamp, assuming the tag is the timestamp and the value is a dictionary with your keys and values:

This dictionary ties text keys to Label components, simplifying extraction later.

firebase_data_changed_timestamped.aia (2.7 KB)
P.S. The firebase component I used was set to the default MIT server, so you would have to adapt it to your server.


how do you know the timestamp value to call back the tag?

According to the OP, it arrives all by itself in the Data Changed event, without having to ask for it, timestamp by timestamp, in real time.

I am taking it on faith that the pump has been primed.

I believe all the data arrives from "readings", which is causing the slow down.

See my solution , getting firebase to do all the work....

I conducted a little experiment on the MIT Firebase server to see if timestamped entries could be caught one by one in a Data Changed event.

It worked for me, using BlueStacks multi-emulators ...

firebase_data_changed_timestamped.aia (4.8 KB)

Note: My List Picker Elements lag behind my Tag Lists because in the interest of speed I only refresh my List Picker Elements when I use the List Pickers, not when new data arrives.

(added to FAQ)

But the OP indicated they wanted the latest / last timestamp ?

In my example, they get the latest added while they are monitoring.

Am I moving the target to fit where the arrow landed?

In my example, I get Firebase to do all the grunt work, and just return the latest/last timestamp value of the tag (that may or may not be the same as the timestamp value - in an earlier screenshot of the data the tag and the timestamp value were different)

Your arrows are rarely, if ever, wide of the mark though :wink:

I will leave it up to the OP which solution fits him.

I have not heard back from him if he has control over the indexing in the database, or if he is stuck at the receiving end with no control.

I would check into Firebase docs to see what they think of indexing on a steadily ascending value like a milliseconds timestamp. Those tend to skew B-tree indexes, unless the technology has improved since I last saw one.

If he goes with an index, it would be interesting to see if the extra index slows down his fast arriving inserts.

Your query definitely gets just the last value, so if he is bouncing among different data collections, that's the way to go.

Sorry bout replying late, I was busy with the other aspects of the project, the thing is, I'm trying to build a real time monitoring system so that the user can see their reading on the MIT application, in real time as they are using the sensors, so if any change in data occurs, they can see it on the app, from firebase, the data is continuously generating when the ESP32 is connected to the internet. so I need the data on the app to be transmitting to the app continuously in real time.

Let us take a few steps back.

Do you want all the readings for a user returned to the app, or just the latest/last reading available for a user, at any given time ?

How often is a new reading generated for a user ?

The readings are being updated on firebase every 6 seconds, I require the latest timestamp, whenever it is updated on firebase to be displayed on the app.


Setup your indexOn as I showed above:


Did do the steps you provided and I have gotten following output,

Screenshot 2023-05-18 222013

As you can see, I did your steps and I have recieved the latest timestamp, however, I do not require the entire data of the timestamp project bucket, rather, I need an individual tag inside it, just like bpm, spo and temperature

That's the same JSON I extract fields from in my earlier post at

Start at the JSONDecodeWithDictionaries.

Why are these two numbers not the same ?


You have two choices:

  1. Make several calls to firebase after you get the latest record for each of the items you want data for (by which time the next record will have arrived....)

  2. Extract the values from the json returned, as @ABG has suggested (or something like that) within the app