Optimizing Repeated Database Queries in Bubble

Hi everyone,

I have a question regarding optimizing repeated database queries in Bubble. In my app, I need to check if a lesson has been watched by the current user. This information is used to change the color of a button and to update an image on the video page.

Currently, I am performing the same query in two different places: once in the button’s conditions and once in the image’s conditions. My concern is whether Bubble optimizes these identical queries to execute only once, or if it performs the query separately each time.

What would be the best practices for handling this scenario to ensure optimal performance?

Put the data into a state or a group element as a data source (if it’s a single piece of data). Then just point any other element or WF to that state/group. Bubble apps are smart enough to not repeat searches but it does incur a small WU cost for initiating a Search.

You can do the same for lists. Store them in a list state. Just note that once stored in a state list, the list state will not update itself. Which is the point. Putting a Search as a datasource incurs a Realtime Data and Fetch Data WU costs.

I NEVER use searches as a data source unless I want realtime updates to a list. I load everything into states.

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.