# How can I reduce Firebase consumption?

**URL:** <https://community.thunkable.com/t/how-can-i-reduce-firebase-consumption/565091>\
**Category:** Questions about Thunkable X\
**Tags:** firebase\
**Created:** [May 8, 2020, 8:25am UTC](https://community.thunkable.com/t/how-can-i-reduce-firebase-consumption/565091 "2020-05-08T08:25:21Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![wikilinks.infooleua0](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/wikilinks.infooleua0/32/68594_2.png) [@wikilinks.infooleua0](https://community.thunkable.com/u/wikilinks.infooleua0)\
**Post date:** [May 8, 2020, 8:25am UTC](https://community.thunkable.com/t/how-can-i-reduce-firebase-consumption/565091/1 "2020-05-08T08:25:21Z")

</div>

Hi everyone, I’m looking for a way to download less data from firebase.

I’m building an app that helps restaurant owners in managing their activities, an integrated system that shows the order taken by the waiter into the kitchen.

To give to the cookers a list of the orders that is always up to date I’m “refreshing” that list every 10 seconds, so if a new order comes in I’m able to show it to them.

I was wondering if there is another system to do it, right now I’m checking every 10 seconds the status of every single item of the order in every table ( see the image below) and this operation costs me a lot in terms of download. (just to give some numbers my whole DB is 25kb and I download 200MB every hour of test.

I was thinking about using the Listener Function but i saw that it can check onli a key per time and is not able to tell me in which node i had the change.  
For example, let’s say that i put the listener on the node **tavoli** , if i change the status of item n6 of the order in table 1 **straccetti** will it be able to tell me where i had that change? Or it will just register a _generic_ change ?

 ![Screenshot 2020-05-08 at 09.54.39](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/5/a59cdf6126e7bca8215427373fa98ccdf52cf6fe.png)

---

<div class="post-metadata">

**Author:** ![eoinparkinson](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/eoinparkinson/32/143769_2.png) [@eoinparkinson](https://community.thunkable.com/u/eoinparkinson)\
**Post date:** [May 8, 2020, 9:21pm UTC](https://community.thunkable.com/t/how-can-i-reduce-firebase-consumption/565091/2 "2020-05-08T21:21:57Z")

</div>

Hi @wikilinks.infooleua0,

> [@wikilinks.infooleua0](#):
>
> I was thinking about using the Listener Function but i saw that it can check onli a key per time and is not able to tell me in which node i had the change.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/1/517c047a114de3db6d4ec9bd58d3c754c6af627f.png)

Setting the key to " / " will listen to your entire database. When any data is changed, the **DataChanged** block on the right can output which key changed and its new value.

200MB/hour seems like a lot of data, especially considering the size of your database. I don’t exactly know if a listener will create higher or lower data transfer amounts, but it seems like the most logical way of going about this.

If your database is updated for example, once a minute, calling a **get** function to the database every 10 seconds is extremely inefficient, whereas the listener would only pull data whenever there is data changed.

---

<div class="post-metadata">

**Author:** ![wikilinks.infooleua0](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/wikilinks.infooleua0/32/68594_2.png) [@wikilinks.infooleua0](https://community.thunkable.com/u/wikilinks.infooleua0)\
**Post date:** [May 10, 2020, 4:12pm UTC](https://community.thunkable.com/t/how-can-i-reduce-firebase-consumption/565091/3 "2020-05-10T16:12:32Z")

</div>

Thank you so much for the answer !

I have two questions:

- if there is a change in the data that has to upload, for example, the orders of a specific table , the action triggered by **data changed** is performed also if I’am in another page of the app ( like for example the kitchen page ) ??

- Does the listener "download data " while watching for changes? Because if it is the case i don’t know if it will solve my data consumption problem.

Thank you again !!!

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [May 10, 2020, 4:57pm UTC](https://community.thunkable.com/t/how-can-i-reduce-firebase-consumption/565091/4 "2020-05-10T16:57:58Z")

</div>

is this in the live companion app or when you download the build that you experience such a large data consumption

> [@eoinparkinson](#):
>
> 200MB/hour seems like a lot of data,

I ask because the live companion will be receiving a lot of data.

---

<div class="post-metadata">

**Author:** ![eoinparkinson](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/eoinparkinson/32/143769_2.png) [@eoinparkinson](https://community.thunkable.com/u/eoinparkinson)\
**Post date:** [May 10, 2020, 5:12pm UTC](https://community.thunkable.com/t/how-can-i-reduce-firebase-consumption/565091/5 "2020-05-10T17:12:44Z")

</div>

When you attach a listener, the client sends the location (and potential query parameters) to the server. The server adds that listener to a list of all listeners of all connected clients. It then also sends back the initial data for that listeners.

Whenever a write operation is committed to the database, the server scans the listeners. For each relevant listener, the server sends an update to the client over the open web socket.

i.e. It is triggered by the write, thus a listener is basically saying I am here whenever you want to send me some data.

---

<div class="post-metadata">

**Author:** ![wikilinks.infooleua0](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/wikilinks.infooleua0/32/68594_2.png) [@wikilinks.infooleua0](https://community.thunkable.com/u/wikilinks.infooleua0)\
**Post date:** [May 15, 2020, 3:46pm UTC](https://community.thunkable.com/t/how-can-i-reduce-firebase-consumption/565091/6 "2020-05-15T15:46:48Z")

</div>

It’s when i use the live companion,  
Thanks

---

<div class="post-metadata">

**Author:** ![wikilinks.infooleua0](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/wikilinks.infooleua0/32/68594_2.png) [@wikilinks.infooleua0](https://community.thunkable.com/u/wikilinks.infooleua0)\
**Post date:** [May 15, 2020, 4:07pm UTC](https://community.thunkable.com/t/how-can-i-reduce-firebase-consumption/565091/7 "2020-05-15T16:07:14Z")

</div>

I’m having another problem, in my app i have to update a list every time a datum changes. (e.g if ths status of an item passes from 0 to 1 it has to be added)

The only way I found for doing that is that every time the listener register a change i send the user for a split second on another screen and send him back to the page where he was. ( it works in this way, but messes up the other screen change actions)

Is there a less “rude” solution to refresh the page ?

Thank you again

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [May 15, 2020, 4:43pm UTC](https://community.thunkable.com/t/how-can-i-reduce-firebase-consumption/565091/8 "2020-05-15T16:43:09Z")

</div>

you should be able to update a list without ever leaving the page. can you show the blocks you ahve used to do this?

---

<div class="post-metadata">

**Author:** ![wikilinks.infooleua0](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/wikilinks.infooleua0/32/68594_2.png) [@wikilinks.infooleua0](https://community.thunkable.com/u/wikilinks.infooleua0)\
**Post date:** [May 15, 2020, 6:41pm UTC](https://community.thunkable.com/t/how-can-i-reduce-firebase-consumption/565091/9 "2020-05-15T18:41:45Z")

</div>

![Screenshot 2020-05-15 at 20.36.37](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/0/e0176bcb489556ee85b1776d4bc49d25dc0c24d4.jpeg)

When the “Produzione” opens i call the listener, if a datum is changed, it opens a dedicated screen " Refresh Produzione" that has the only task to bring u back to Produzione when opened.

Before ding this i had in te " When Data Change" a call for the porocedure that writes the items in the list.

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 11:26am UTC](https://community.thunkable.com/t/how-can-i-reduce-firebase-consumption/565091/10 "2024-11-08T11:26:45Z")

</div>


