Free Workload Unit (WU) Optimization Guide by Airdev

Just a quick note about the search:count is 0 compared to search: first item is empty example…

Search: first item is empty will always perform a search (0.3. WU) and retrieve the first item from the database if there is one (0.015 WU plus the cost for the amount of data - so a minimum of 0.315 WU - and on heavy database items it can be 2-4 times that - 0.69 in your example)…

So it will always be more costly in WU than simply checking the count - which only requires an aggregate search, and doesn’t retrieve any data - so only ever costs 0.2 WU

There seems to be a bug in Bubble, with the way the number 0 in the expression search:count is 0 is evaluated, which changes the aggregate search into an actual search and returns the first 10 items - hence why it costs exactly 10 times more in WU in your example (once you deduct the cost of the search itself) than the expression search: first item is empty

But the issue seems only to be with the number 0 (and only when it’s manually typed into the expression) - any other number used in the expression results in an aggregate search (as expected), and a WU cost of only 0.2 (as expected) regardless of the size or amount of data involved.

In any case, the expression search:count < 1 will always be a more WU efficient way to establish this than search: first item is empty (even when there are no items returned by the search, search: first item is empty will cost 0.3 WU whereas search:count < 1 will cost 0.2 WU).

For further context, see this post: Search: count is 0? Or Search:first item is empty? - Tips - Bubble Forum

11 Likes