Do a search for... vs Advanced Filters

Hey Bubblers!

I hope you are all having a great weekend!

I was wondering if someone could answer my question regarding if Doing a search for a long list of data would be faster and less performance heavy or if doing a search within some data with an advanced filter would be better. I will give an example.

For example, let’s say I have 100,000 blog posts or something similar stored in a type called “Blog” then have a field inside of that called “User” with the type user and another field called “Active”. In addition, I also have a field inside the user called, “Written Blog Posts” which is a list of “Blog.”

Would doing a search for “Blog” with constraints on a user’s active blog posts be faster or would be grabbing the list of blog active blog posts from the user type be faster with an advanced filter?

If this didn’t really make any sense please feel free to reply for clarification:)

Thanks ahead of this!

It is always faster to do any filtering that you can on the server side.

Ultimately, you may not be able to get your desired, fully filtered list that way. But do as much filtering in the Search as possible and then do any required Advanced filtering on that as-small-as-possible list.

I present a real-world performance comparison of doing things the smart way vs. doing things the slow way here (the topic in question asks about :merge vs :filter, but I’m sure you’ll see how this applies in a great many other situations – read the whole thread for context):

2 Likes

Just to clarify, are you saying that if I use the Do a search for… with constraints it would be faster than if I do :filter?

It’s hard to explain, so if I had a data type with a lot of entries and started to also save them under a user, would it be faster to just search for the big data type with constraints or searching the data in the user with filters?

So, if you look at the post I linked to, the point is that you always want to prune the list you are sending down to the browser as much as possible.

Don’t just grab ALL the Things. Grab only the list of Things that could possibly pass the Advanced filter you’re going to do later. That is, optimize your search to include only those items that you don’t already know will be excluded later.

Only you can know what criteria you might use for this.

But as you suggest: You have a “Blog” data type and on that there’s a concept of “active”. If you’ve set up your database correctly, you can simply:

Do a Search for... Blog (constraints: Created by {User in Question}, Active = yes)

As I said, this will always be faster than downloading all “Blog” items and filtering in the browser.

The issue being: What if your database has 100,000 Blog items? Well, first, you’ll never be able to download all of those the browser (Bubble will not allow that). But even then, if you say, “Well, I’m not dumb, of course I’m going to limit my Search to only those Blogs created by some specific User”, taking that list and then :filtering in the browser (for only those Blogs that are “active” – whatever that means) will be slower than if you can limit the Search to only return the “active” blogs.

NOW, if you’ve got your database set up in such a way that you cannot construct the Search criteria for “active” blog then you might want to consider setting up so that you can, if this is something that you’re going to commonly do.

But I’m guessing that your Blog data type is set up just fine and your question is academic. If so, just know that what I’m saying is 100% correct. You can test it if you want, but what you’ll have to do is construct a database with a bunch of phony blog posts. (You can do that with List Shifter and some patience, but there’s no need. Limiting the number of returned items at the Search step is always faster than downloading a larger number of search items and filtering in the browser… at least for any scenario where the difference in these two approaches is measurable.)

7 Likes

Thank you for your response. So long story short, just try to narrow and prune out what I’m looking for then filter the specific items out.

2 Likes