Best way to sort a repeating group (Help)

Hello everybody. I would like to display items from a list in the repeater group from newest to oldest, as is normally the case in a chat .

I use the timeStamp field to perform sorting. But it turns out that when creating this sorting, the response and display time of messages is brutally increased.

I’ve already tried “search for” and also a field list of messages, but both have a very long delay in the response of the messages, since when I don’t insert any order, the presentation of the messages is almost instantaneous.

The tests were with an amount of approximately 500 messages for this user the total number of messages in the database is 45 000.

1 - Messages without any sorting in message list field.;


2 - Query in message list field with sorting;


While it does not finish for all this time, the RP does not display any information.

3 - Now, serch for with sorting;


4 - Search for without sorting;


So I would like advice on the best way to do this sorting.

Hi, for someone to help you with this, you’ll need to screenshot sections from the editor showing your search structure.

The problem is in how you’ve set it up, since sorting by itself wouldn’t cause this issue.

1 Like

You’re right, I’ve just inserted the images in all 4 ways I’ve tried to do this query.

I can’t understand the reason for the slowness.

Add privacy rules so that only the intended user’s messages are sent from the server over to the page. This reduces the number of messages to be managed, sorted, searched, filtered … etc.

1 Like

when you have 500 messages do a search for should be much faster than “Xs list of messages”.

from my experience even if n= 1M, do a search for is fast.

maybe add more constraints such as " timestamp is not empty" or “chat is not empty”

is your timestamp formatted correctly?


Thanks for the reply.

The only privacy rules I managed to create were:
Show Patients (Chat) only from the current user’s company.

And also messages that are from the current user’s company.

How to make one more rule to show only the selected Patient (Chat)? It’s possible?

Thanks for helping me.

That’s right, I also realized that a search is faster than a list, this option has already been discarded.

Still the response time is great even with this small number of messages.

I’ll consider the empty timestamp filter suggestion.

About the timestamp I already leave it saved with seconds, initially I thought it was a problem, but now it doesn’t seem to be.

you can also reach out to via email as I am a little surprised it takes this long. one question before this:

in each chat message in your repeating group, i see you are using "parent groups messages conversation:find & replace… find replace… what is reason for this? why not just parent groups messages: text.

also be sure not to have “do a search for inside do a search for”, ie nested search. or search:filtered anywhere.


I can send an email yes.

As for using find & replace, it is because I receive these messages directly from the WhatsApp API that contain ** for bold and __ for italics which I replace with regex for [b][/b] or [i][/i] as in picture below;

I don’t do any search for within the message result

oh ok so it is not just a normal chat with 1 chat and its many text message but in each repeating group row you use the whatsapp API to gather more data? not surprised this is slow.
can you share the datasource and details for this?

No, I don’t collect any more data after the message is created in the database. this is the structure of the message.

Each message sent or received on whatsapp is created a new message in the app. So I do a search of all messages exchanged with the selected chat and present them in the RP, no queries are made within the RP either internally or via the API.

ok i understand.
it is similarly slow without regex?
i would try this and then contact bubble support.

1 Like

A sorting delay can arise when Bubble is forced to download all data client side (to the browser) and then sort from there.

See the below from Josh related to sorting…

I.e., if you have 10,000 items and are only showing 10 in the RG, if your sort is done server-side (by Bubble) it quickly finds the 10 you need and only sends those 10 to the browser. But if you sort client side (on the browser), then Bubble needs to download 10,000 items to the browser and then sort them there.

If you are using APIs to pull in data from outside of Bubble, that’s beyond me since I’ve only worked with data stored in Bubble. However I can speculate that there could be a scenario where you are asking for a sort, which forces Bubble to download all the data from the external data source, and then do a sort on the browser (client side). To get around this, I’d think you’d need to set it up to where the API is asking for sorted data from the source, so that only the results are sent.

In your Google devtools screens which you’ve screenshot, you can click around in there to see exactly what is being loaded. I’ve found that’s the best way to understand exactly what Bubble is doing.


@TipLister I saw the class, I understood that how it works until a certain moment.

Could you answer my question below?

How to create a constraint in a Data API query to get a list of messages belonging to a chat?

I read the Bubble documentation on the subject but I couldn’t get it to work.

Can you understand me?

what are you trying to do?

lets say my chat has 20 messages.
do you want to add a constraint to only display 10 of them?

in this case you do not do this in the api query but in the frontend so you make datasource of the Repeating group
get data from external api: filtered and add constraint where it says filtered

other option is you want to do something with the “list”
check documentation of another api eg google calendar here they also have a list event.

here in my api connector, see where it says attendees.