Workload optimization

Hi dear friends,
Fetching data is eating up about 55% of my WU.
So my question is if I delete older records from the database, will it reduce the WU usage and cost me less?
I know it’s counterlogic of creating the app and then deleting user’s older data but I might have to go this way to keep my app alive.
Thank you!

@maratnasy2 instead of deleting those records, you could add a constraint to your search where for example Created Date > Current Date/Time - 14 days. This would retrieve only those records that have been created in the past fortnight

1 Like

Thanks, that makes sense.
This may note work in all app pages but it helps.

I’d be curious to see what else you are doing when you’re fetching.

I am not 100% certain, but if I am getting (for example) 1000 rows from the database, and each row has an inventory item, and you are going out and getting the name of that inventory item from another table for each of those rows, that just adds more WU usage to your fetch.

To be honest, I am not exactly sure what “Fetching Data” is. I am new to Bubble. I guess Fetching means pulling data from the database to show it to app users. In my app it is getting text and images from the DB.
I will have to test as noted above hoping it will reduce WU usage. But isn’t searching the database uses the WU anyway, regardless what conditions you have for the search? Meaning the less database the less WU usage?

Are you using Privacy Rules?

If you are not, and are only checking for the conditions on the front end, every data piece is pulled that can be pulled (to some degree), and then filtered in the front end to only show what you need.
If you set these Privacy Rules, the data is filtered at database level and it will not go to the front end, saving WU in the amount of data requested, the amount of data sent and the amount of data filtered.

For your reference, @maratnasy2.

1 Like

If you set these Privacy Rules, the data is filtered at database level

True, but this is also true for constraints. Only :filtered is doing client side filtering, and then even with :filtered some actions can happen on the server if I’m not mistaken.

Nonetheless, privacy rules are definitely a must to keep your app secure!

2 Likes

I stand corrected then. I thought it was less secure than that.
Thanks for ending up helping me :slight_smile:

1 Like

Thank you for all responses!
I think Privacy Rules are not directly applicable to my app data that is being pulled from the DB. There is nothing private in the request that User sends and then receives an answer (text+image) which is being retrieved from the DB depending on the type of request.
So given my basic level of Bubble understanding, is it true the smaller the DB (less rows) the less Fetching data and therefore less WU usage?

Unless I have completely misunderstood how it works (and I don’t believe that is the case), it has nothing to do with how many rows you have in your database. A search has a flat cost associated with it, and the number of characters and results returned from the database have costs associated with them (you can see all of that at the link I provided in my other reply). So, in a nutshell, you reduce the WU costs associated with a search by making sure you constrain the search so it returns as few data as possible (i.e., only the data you need).

2 Likes

No worries! And yes you’re right - relying solely on constraints IS less secure. You want to set up your privacy rules as tight as possible. Allowing access only to the data essential for your end users. Then, you would want to use constraints in addition to fetch the specific data set required.

So, for example, imagine you have a page that displays only the Leads for a specific Company with the status “Needs follow-up.” First, you set up privacy rules to ensure that these Leads are visible only to your company, which, yes, also helps to save some WUs. Next, in your search function, you implement a constraint to retrieve only those leads with that specific status, saving even more WUs.

Hopefully this is clear! :slight_smile:

1 Like

You’re probably wrong. Unless you’re explicitly telling Users that they can see each other’s requests in your privacy policy, you need privacy rules.

2 Likes

Thank you so much for all your answers.
I will have to rethink how I structure my app. Search with constraints and Privacy rules, that seems to be a way to go to reduce WU usage.
On a side note, it would be great if Bubble could provide a more granular breakdown of WU usage so that we can see where we can restructure the app.

Thank you, that’s very helpful to learn.

1 Like