:count operator returns all items from DB (not only count) when you have several searches within same data type

Recently I’ve been playing with :count operator. And found out a strange Bubble behaviour: if you have several searches for entries from the same Data Type followed by :count operator and one of the searches doesn’t have any constraints - Bubble will send you all entries from DB, not only their total count.

Data Structure

  1. SaaS
    1.1 name (text)
    1.2 pricing model (Pricing Option Set)

  2. Pricing Option Set (“free”, “freemium”, “paid”)

Tests execution

Test #1 :white_check_mark:
1 text element on the page. Text is dynamic expression Do a search for SaaS: count [no constraints]

Result:

Test #2 :white_check_mark:
1 text element on the page. Text is dynamic expression Do a search for SaaS: count [constraints: “pricing model” = “free”]

Result:

Test #3 :white_check_mark:
2 text elements on the page:

  • Text element 1: dynamic expression Do a search for SaaS: count [constraints: “pricing model” = “free”]
  • Text element 2: dynamic expression Do a search for SaaS: count [constraints: “pricing model” = “paid”]

Result:

Test #4 :x:
2 text elements on the page:

  • Text element 1: dynamic expression Do a search for SaaS: count [no constraints]
  • Text element 2: dynamic expression Do a search for SaaS: count [constraints: “pricing model” = “paid”]

Result:

I can’t understand why in Test #4 I’m getting ALL entries from DB in addition to their count. In big apps with thousands of entries this will be a workload killer and devs may not even be aware that this is happening.

Continued my investigation. Tested with groups and “display data” actions.

Test #5 :x:
2 group elements (type of content = number) on the page:

To populate groups with data I use a single WF with two subsequent “display data” actions:

  • Action #1 → data to display in Group 1 = Do a search for SaaS: count [no constraints ]
  • Action #2 → data to display in Group 2 = Do a search for SaaS: count [constraints: “pricing model” = “paid”]

Result:

Test #6 :white_check_mark: [just changed the order of actions from Test #5]
2 group elements (type of content = number) on the page:

To populate groups with data I use a single WF with two subsequent “display data” actions:

  • Action #1 → data to display in Group 1 = Do a search for SaaS: count [constraints: “pricing model” = “paid”]
  • Action #2 → data to display in Group 2 = Do a search for SaaS: count [no constraints ]

Result:

So as we can see the order of actions affects the outcome of applying :count operator and if you mess with it - say “hello” to high workload consumption.
Is that a bug or a feature?

I have found one of the biggest WU contributors is this function, just counting records and not actually sowing the records on the screen is using massive amounts of ‘WU’s’.

Do you have any elements referring to any fields from SaaS or are you just displaying the count as text?

Not even displaying text, I am using it as a condition to show an icon, so - if records count < 1 show X icon, or if records count > 1 show X icon..

EDIT - to clarify, this condition is in a repeating group so shows up 30 times on one page.

Tests #1 - Test #4: just displaying :count result in a text field
Test #5 - Test #6: sending :count result to empty groups (no display at all)

Something suspicious is going on…

  1. Created a couple of brand new apps and can’t reproduce issues from Test #4 and Test #5.
  2. Tested in a couple of sandbox apps created until today (latest one created on April 10th) - issues can be reproduced

:exploding_head:

P.S. If anybody has quite a bit of free time to test one of issues mentioned above in your sandbox app (test can be performed within 5 minutes) - PM me, please.

Just wanna add an update that I got from the support team. The reason is that if the first (full) :count is relatively small - it’s faster for Bubble to load whole search as a result for second (filtered) :count (cause they know that filtered count will not be larger than full count).
So sometimes (on small volume of data) we can get whole things (with all attributes) from the DB, not just their count.

1 Like