Thank you for this guide (Firebase).It saved me plenty of time (two afternoons instead of days to create own project).
Based on Firebase guide I created own project with six temperature sensors saved to DB every 30s. The goal is even shorter tim up to 2s. When there is not to many records in DB (I estimate up to one hundred, but not confirmed by a test)) all is OK. The problem is after opening web app after 2-3 days (3*24*60*20=8640 records). There is a few minutes (2-10min) lag on Android device. Much shorter on PC web browser, but also 30-60s. What could be a reason? Sometimes I also observed gradual change in Last Update field (time was step by step increased). After this initial lag further controll seems to be OK. Also there is not mentioned startup lag after data delete.
1. Is it any way to speed up this? May be change search DB process?
2. If not may be a way to automatically clear older records (having only a few hundreds in DB)?
If you have a lot of records on the database and try to load them all at once, the browser will lag and may even crash.
Are you displaying all records on the web browser or only the latest?
We have this project that has a delete button to delete database records and also shows how to load only 100 readings at a time:
I hope this helps.
What is a reason of browser crash you mentioned?
My project is based on your eBook https://randomnerdtutorials.com/firebase-esp32-esp8266-ebook/ so there is delete button on the site. But first all data are deleted, second it must be done manually.
Finally, I need only last few hours be displayed. Assuming 4 hours it is now 480 records but current project, based on eBook, displays only 30 last readings on the charts.
It is any way to design Firebase RTDB to automatically delete records (based on time or its quantity)?
Also delete oldest records by ESP32 device during saving fresh data seems work for me. Could it be done? How should I modify ESP code?
Last option (not as ideal as two previous) is a modification of delete button action to delete not all records but sustain some of them. How web page code could be modified to get this?
There is not an easy way to delete entries automatically.
Here are some options: https://stackoverflow.com/questions/32004582/delete-firebase-data-older-than-2-hours
You can also make requests on the ESP32 to delete data.
You can filter the data before deleting it so that you only delete the oldest entries:
I don’t have anything specific written for that at the moment, but I think the links for the documentation I shared should help.