# Improvement in implementation of “:count is 0”

**URL:** <https://forum.bubble.io/t/improvement-in-implementation-of-count-is-0/339071>\
**Category:** Announcements\
**Created:** [September 12, 2024, 2:13pm UTC](https://forum.bubble.io/t/improvement-in-implementation-of-count-is-0/339071 "2024-09-12T14:13:16Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![allenyang](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/allenyang/32/209425_2.png) [@allenyang](https://forum.bubble.io/u/allenyang)\
**Post date:** [September 12, 2024, 2:13pm UTC](https://forum.bubble.io/t/improvement-in-implementation-of-count-is-0/339071/1 "2024-09-12T14:13:16Z")

</div>

Hello all,

We’re excited to share an improvement to the implementation of how the “:count is 0” operator in a dynamic expression works. Behind the scenes, we’ve changed how we implement “:count is 0” so that it returns only the data it needs to check if the count of items is empty, which should be a minor boost to performance and also a reduction in workload.

Specifically, this implementation improvement will reduce the workload used by “:count is 0” because it will return less data from the database (one of the activity types in the workload formula). It will reduce workload more in situations where the individual things of a data type being counted tend to contain more data and thus are bigger in size; returning less data from the database means the total size of the data returned is smaller. The workload formula remains the same, but “:count is 0” will use this activity type less intensively.

Thank you to the users who have shared this feedback!

Let us know if you have any questions!

All the best,  
Allen

---

<div class="post-metadata">

**Author:** ![bek](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/bek/32/169143_2.png) [@bek](https://forum.bubble.io/u/bek)\
**Post date:** [September 12, 2024, 2:32pm UTC](https://forum.bubble.io/t/improvement-in-implementation-of-count-is-0/339071/2 "2024-09-12T14:32:37Z")

</div>

Thansk @allenyang. To confirm, “:count is 0” should now be the go to for checking if a list is empty, is that correct?

---

<div class="post-metadata">

**Author:** ![filipefmenezes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/filipefmenezes/32/223202_2.png) [@filipefmenezes](https://forum.bubble.io/u/filipefmenezes)\
**Post date:** [September 12, 2024, 2:34pm UTC](https://forum.bubble.io/t/improvement-in-implementation-of-count-is-0/339071/3 "2024-09-12T14:34:02Z")

</div>

Wow, no more needing to remember whether to use “first item is empty,” “count is 0,” or “count \< 1.” Nice!

---

<div class="post-metadata">

**Author:** ![artemzheg](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/artemzheg/32/9651_2.png) [@artemzheg](https://forum.bubble.io/u/artemzheg)\
**Post date:** [September 12, 2024, 2:35pm UTC](https://forum.bubble.io/t/improvement-in-implementation-of-count-is-0/339071/4 "2024-09-12T14:35:45Z")

</div>

Just to be sure, is this fixed with `:count is 0` improvement?

> [@Search: count is 0? Or Search:first item is empty?](https://forum.bubble.io/t/search-count-is-0-or-search-first-item-is-empty/265743):
>
> So, since the change in pricing model, and the introduction of WUs, I’ve spent a LOT of time (probably way more than it’s worth) testing many, many things in Bubble to establish the most WU efficient ways of doing standard (and not so standard) things, especially in relation to loading related data (lists versus no list etc.) and bulk data processing. I’ve been tempted to publish my findings so far, for the benefit of others, but I’ve held back as I’m yet to be convinced that it’s actually a wo…

---

<div class="post-metadata">

**Author:** ![boston85719](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/boston85719/32/77286_2.png) [@boston85719](https://forum.bubble.io/u/boston85719)\
**Post date:** [September 12, 2024, 2:36pm UTC](https://forum.bubble.io/t/improvement-in-implementation-of-count-is-0/339071/5 "2024-09-12T14:36:23Z")

</div>

I want to be able to return less data from the database.

---

<div class="post-metadata">

**Author:** ![Jici](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jici/32/30722_2.png) [@Jici](https://forum.bubble.io/u/Jici)\
**Post date:** [September 12, 2024, 2:36pm UTC](https://forum.bubble.io/t/improvement-in-implementation-of-count-is-0/339071/6 "2024-09-12T14:36:44Z")

</div>

So just to be sure I understand correctly, this will always perform a msearch request but return less data or it’s now performing a maggregate request?

Good news by the way 🙂

---

<div class="post-metadata">

**Author:** ![georgecollier](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/georgecollier/32/182327_2.png) [@georgecollier](https://forum.bubble.io/u/georgecollier)\
**Post date:** [September 12, 2024, 2:48pm UTC](https://forum.bubble.io/t/improvement-in-implementation-of-count-is-0/339071/7 "2024-09-12T14:48:25Z")

</div>

This would be big if true. Unfortunately, it seems that Do a search:count is 0 still performs a search request, _not_ an aggregate request, despite :count being an aggregate query. Even if it doesn’t return things from the DB (as would be expected from a :count), it still costs more WU, and that seems to be an error on Bubble’s side.

The simple case of an unconstrained Do a search for Things:count is 0 should always cost only 0.2 WU (cost for an aggregate search), and should have no Things returned from the DB.

However, I can see from the network tab that it still performs a search, which costs 0.3 WU.

Meanwhile, if I do `:count is (any positive integer)`, it does an aggregate request and costs 0.2 WU.

There’s still _clearly_ a difference between `:count is 0` and `:count is {positive integer}`.

`:count is 0` costs 0.3 WU and `:count is {positive integer}` costs 0.2 WU.

Why?

Edit: adding images

 ![CleanShot 2024-09-12 at 17.07.16@2x](https://us1.discourse-cdn.com/bubble/original/3X/7/3/735893273b5cb8a346440dea4c11a4f2864a0fdd.png)  
 ![CleanShot 2024-09-12 at 17.11.04@2x](https://us1.discourse-cdn.com/bubble/original/3X/f/9/f9d79ba70b592018119510ccc9d51b5249ee69dd.png)

---

<div class="post-metadata">

**Author:** ![adamhholmes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/adamhholmes/32/100510_2.png) [@adamhholmes](https://forum.bubble.io/u/adamhholmes)\
**Post date:** [September 12, 2024, 3:11pm UTC](https://forum.bubble.io/t/improvement-in-implementation-of-count-is-0/339071/8 "2024-09-12T15:11:47Z")

</div>

> [@Jici](#):
>
> So just to be sure I understand correctly, this will always perform a msearch request but return less data or it’s now performing a maggregate request?

Seemingly, it’s the former… it still performs an msearch (for some reason), but rather than returning the full data of the first 10 items (which is what it always did before in my testing), it now only retrieves the first item, and _only_ the Unique ID of that item. So, depending on the size of the data it may well be a lot less data.

But that means it still costs 0.3 WU instead of 0.2 - which is still 50% more than it should be, and still 50% more than using the number 1 instead of the number 0.

> [@georgecollier](#):
>
> Meanwhile, if I do `:count is (any positive integer)`, it does an aggregate request and costs 0.2 WU.
> 
> There’s still _clearly_ a difference between `:count is 0` and `:count is {positive integer}`.
> 
> `:count is 0` first costs 0.3 WU and `:count is {positive integer}` costs 0.2 WU.
> 
> Why?

It’s even more specific than that, in that it’s the number 0, _only_ as a _literal_ value that causes the problem.

If it’s a variable (i.e. a custom state) it works fine and just performs an agg search.

> [@bek](#):
>
> To confirm, “:count is 0” should now be the go to for checking if a list is empty, is that correct?

Nope…

Even with this ‘fix’ `count is 0` still costs exactly 50% more in WU than `count < 1`

---

<div class="post-metadata">

**Author:** ![georgecollier](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/georgecollier/32/182327_2.png) [@georgecollier](https://forum.bubble.io/u/georgecollier)\
**Post date:** [September 12, 2024, 3:13pm UTC](https://forum.bubble.io/t/improvement-in-implementation-of-count-is-0/339071/9 "2024-09-12T15:13:32Z")

</div>

> [@adamhholmes](#):
>
> If it’s a variable (i.e. a custom state) it works fine and just performs an agg search.

brb, creating ‘var - 0’ in every application  
 ![CleanShot 2024-09-12 at 17.12.53@2x](https://us1.discourse-cdn.com/bubble/original/3X/5/e/5edd159f614cfedf01d067dafc8ab77e36321a51.png)

Just tested, and you’re still correct, `Search for Things:count is var - 0's number` does an aggregate search!

---

<div class="post-metadata">

**Author:** ![jefeoliveira22](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jefeoliveira22/32/235680_2.png) [@jefeoliveira22](https://forum.bubble.io/u/jefeoliveira22)\
**Post date:** [September 12, 2024, 3:23pm UTC](https://forum.bubble.io/t/improvement-in-implementation-of-count-is-0/339071/10 "2024-09-12T15:23:56Z")

</div>

Why is the community explanation better than a Bubble employee?

> which should be a minor boost to performance and also a reduction in workload.

What kind of announcement is that?

---

<div class="post-metadata">

**Author:** ![ahmed.elkaffas](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/ahmed.elkaffas/32/246772_2.png) [@ahmed.elkaffas](https://forum.bubble.io/u/ahmed.elkaffas)\
**Post date:** [September 12, 2024, 3:30pm UTC](https://forum.bubble.io/t/improvement-in-implementation-of-count-is-0/339071/11 "2024-09-12T15:30:55Z")

</div>

I have read a lot about the difference between “count is 0” & “first item:is empty” and of course I am using the latter almost everywhere to check for a value.  
The community responses show that we shouldn’t yet use “count is 0” so I won’t change anything for now until further announcement !

---

<div class="post-metadata">

**Author:** ![adamhholmes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/adamhholmes/32/100510_2.png) [@adamhholmes](https://forum.bubble.io/u/adamhholmes)\
**Post date:** [September 12, 2024, 3:47pm UTC](https://forum.bubble.io/t/improvement-in-implementation-of-count-is-0/339071/12 "2024-09-12T15:47:09Z")

</div>

> [@ahmed.elkaffas](#):
>
> The community responses show that we shouldn’t yet use “count is 0” so I won’t change anything for now until further announcement !

True this fix offers only a slight improvement when using `count is 0`, but using `count < 1` is still better than `first item is empty` (in some cases significantly).

Using `first item is empty`:

In cases where the first item _is_ empty (i.e. there are _no_ existing items in the database), it costs 0.3 WU for the search.

In cases where the first item is _not_ empty (i.e. there _is_ an existing item in the database) it will cost 0.3WU for the search, 0.015WU to retrieve the first item, _plus_ however many WU it costs for the amount of data retrieved.

Using `count < 1` will only ever cost 0.2WU.

---

<div class="post-metadata">

**Author:** ![Jici](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jici/32/30722_2.png) [@Jici](https://forum.bubble.io/u/Jici)\
**Post date:** [September 12, 2024, 3:47pm UTC](https://forum.bubble.io/t/improvement-in-implementation-of-count-is-0/339071/13 "2024-09-12T15:47:42Z")

</div>

Other options: count \< 1 will do a maggregate search and cost less WU (var options is also possible like @adamhholmes) . When you need greater than 0, you should also use \>= 1 instead

---

<div class="post-metadata">

**Author:** ![brenton.strine](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/brenton.strine/32/124156_2.png) [@brenton.strine](https://forum.bubble.io/u/brenton.strine)\
**Post date:** [September 12, 2024, 3:48pm UTC](https://forum.bubble.io/t/improvement-in-implementation-of-count-is-0/339071/14 "2024-09-12T15:48:29Z")

</div>

> [@ahmed.elkaffas](#):
>
> I have read a lot about the difference between “count is 0” & “first item:is empty” and of course I am using the latter almost everywhere to check for a value.

Actually the best practice till now has been `:count <1` rather than `:first item is empty` (see [https://x.com/brentonstrine/status/1819054939911434714](https://x.com/brentonstrine/status/1819054939911434714))

With this announcement, it seems `:count is 0` is now actually better than `:first item is empty` **but still not as good as `:count<1`**

---

<div class="post-metadata">

**Author:** ![fede.bubble](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/fede.bubble/32/215574_2.png) [@fede.bubble](https://forum.bubble.io/u/fede.bubble)\
**Post date:** [September 12, 2024, 4:04pm UTC](https://forum.bubble.io/t/improvement-in-implementation-of-count-is-0/339071/15 "2024-09-12T16:04:56Z")

</div>

I see this as more of a quick win the team was able to put together outside of their roadmaps than a “fix”. It’s better than before, maybe not perfect, but better.  
As always, I’ll keep passing everyone’s feedback to team so we can keep getting better

---

<div class="post-metadata">

**Author:** ![brenton.strine](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/brenton.strine/32/124156_2.png) [@brenton.strine](https://forum.bubble.io/u/brenton.strine)\
**Post date:** [September 12, 2024, 4:10pm UTC](https://forum.bubble.io/t/improvement-in-implementation-of-count-is-0/339071/16 "2024-09-12T16:10:40Z")

</div>

This is

> [@fede.bubble](#):
>
> I see this as more of a quick win the team was able to put together outside of their roadmaps than a “fix”. It’s better than before, maybe not perfect, but better.  
> As always, I’ll keep passing everyone’s feedback to team so we can keep getting better

This is a huge win for all the apps out there built with `:count is 0`. In fact this is now even better than `:first item is empty` so that’s great news!

This meme isn’t quite accurate just yet… but some day it will be!

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/c/e/ce5910888dab44463cda1cee3d54338acc54f222.jpeg)

---

<div class="post-metadata">

**Author:** ![adamhholmes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/adamhholmes/32/100510_2.png) [@adamhholmes](https://forum.bubble.io/u/adamhholmes)\
**Post date:** [September 12, 2024, 4:12pm UTC](https://forum.bubble.io/t/improvement-in-implementation-of-count-is-0/339071/17 "2024-09-12T16:12:29Z")

</div>

> [@fede.bubble](#):
>
> I see this as more of a quick win the team was able to put together

Quick?.. it only took 15 months!

But yes… it _is_ an improvement 🙂

---

<div class="post-metadata">

**Author:** ![ahmed.elkaffas](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/ahmed.elkaffas/32/246772_2.png) [@ahmed.elkaffas](https://forum.bubble.io/u/ahmed.elkaffas)\
**Post date:** [September 12, 2024, 4:25pm UTC](https://forum.bubble.io/t/improvement-in-implementation-of-count-is-0/339071/18 "2024-09-12T16:25:38Z")

</div>

Thanks all for your detailed responses !

---

<div class="post-metadata">

**Author:** ![fede.bubble](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/fede.bubble/32/215574_2.png) [@fede.bubble](https://forum.bubble.io/u/fede.bubble)\
**Post date:** [September 12, 2024, 5:28pm UTC](https://forum.bubble.io/t/improvement-in-implementation-of-count-is-0/339071/19 "2024-09-12T17:28:45Z")

</div>

> [@adamhholmes](#):
>
> Quick?.. it only took 15 months!

From my point of reference when I started asking about it internally 😆

---

<div class="post-metadata">

**Author:** ![brenton.strine](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/brenton.strine/32/124156_2.png) [@brenton.strine](https://forum.bubble.io/u/brenton.strine)\
**Post date:** [September 12, 2024, 5:45pm UTC](https://forum.bubble.io/t/improvement-in-implementation-of-count-is-0/339071/20 "2024-09-12T17:45:29Z")

</div>

> [@adamhholmes](#):
>
> Quick?.. it only took 15 months!

I think what this shows is that Bubble has put into place better processes to capture and handle issues like this… and it’s working! We now have the Bubble Ambassadors, and Fede and we have much better ability now to bend the ears of Bubble engineering leadership for things.

I’m a Bubble Ambassador and [I started making noise about this again on August 1st](https://x.com/brentonstrine/status/1818980703737929913)–both in internal channels and publicly. With the new processes in place it only took 1 month 12 days. That’s actually a remarkable turnaround time! Consider all the steps Bubble had to go through

1. Receive the feedback
2. Filter it and recognize it as an important thing that needs to be fixed
3. Prioritize it against other priorities
4. Schedule engineering time, reallocate resources.
5. Come up with a plan to fix it.
6. Engineers actually fix it.
7. Test & Deploy

It’s actually a remarkably fast turnaround time.

[Next page](https://forum.bubble.io/t/improvement-in-implementation-of-count-is-0/339071.md?page=2)
