Optimizing Search Performance in a Massive DB for Grocery Marketplace App on Bubble

Hello everyone,

Looking forward to a Happy New Year!

PROBLEM
I am having difficulty with my bubble app’s performance, namely that it is quite slow when performing search functions based on queries to bubble’s built in database (the page takes 20 seconds to load a repeating group, ideally this goes down to 6 seconds or less).

Happy New Year! I’m currently developing a grocery marketplace app in Bubble that integrates products from multiple retailers. As the app scales to hundreds of thousands of products (and millions at full scale), I’m facing significant performance challenges, specifically with search functionality. I’m looking for insights on optimizing database performance to improve search speed.

I’ve designed the search functions and database to be as efficient as possible using Bubble’s native database system. The structure is centered around a ‘Product-Generic’ datatype, which stores basic information about products commonly found across different locations of the same grocery store brand. Each ‘Product-Generic’ entry includes a field named ‘Product-Instances’, a list containing another datatype, ‘Product-Instance’. This nested datatype holds extensive details like pricing and availability for each product specific to an individual store location.

Currently, I have a RepeatingGroup searching for “product-generics” (of which there are 3000 in the test db) based on some conditions the user inputs and then filters the list of “product-instances” nested within the “product-generics” based on which store the user is shopping at and whether they’re filtering for a sale item. Attached are some images to visualize this.

I feel that this is as lean as the database and search function can be and the live version will need to grow from 3000 “product-generics” to many thousands at scale, yet the search queries take 20 seconds to load.

Is there anything I can do to improve performance? THANK YOU ALL!


1 Like

You should avoid using filters and possibly look into optimizing your database to prevent having to go inside generics to fetch product instances.

One way would be to find unique product instances grouped by generic.

Another resort would be using Algolia, we recently set this up for a construction site with over 100,000 records and instant search results

3 Likes

Algolia is the way to go for instant complex queries.

2 Likes

Thanks for the tip on nesting, I reverted to just searching for the product instances and the app is now much faster. For whatever reason I assumed searching for 3000 product generics and nesting the 10,000 product instances inside them would be quicker than parsing through the 10,000 straight away but I was incorrect.

I had come across Algolia when researching this issue and it seems to be the consensus best way to proceed. Do you have any good resources (links are great but love video tutorials as well) that I can use to switch catch me up to speed as I switch my database querying over?

1 Like

Thanks for the tip! I had come across Algolia when researching this issue and it seems to be the consensus best way to proceed. Do you have any good resources (links are great but love video tutorials as well) that I can use to switch catch me up to speed as I switch my database querying over?

We don’t have documentation to share. Our team tailors the approach for each project based on its specific requirements.

To start, you will need to create a record of each object inside algolia using json and the api connection.

2 Likes

Many thanks for the advice!

Although I agree with both of them that Algolia is a great option & will make things instant I don’t believe it is the solution you’re looking for.

Building bandaid fixes on top of a poorly optimized core structure will lead to large amounts of tech debt that typically just pile onto eachother until your app is literally unusable and as much as I love Algolia for its quick searching, beautifully done ranking/sorting algorithms, flexible search, user specific recommendations, and so fourth it is usually my last stop due to cost & maintenance (specifically when sync errors happen).

Bubble is scaleable even with millions of records when built correctly. Algolia should be a late stage scaling tool or used to hyper optimize your marketplace while running large amounts of paid traffic.

Just my opinion but due to the size and expected scale of your app this doesn’t seem to be a short term project for you. If it’s plausible I’d recommend focusing on taking a 48 hr break from building, sitting down and reading the entirety of manual.bubble.io.

Both the issues that are causing your very long load times are explicitly recommended against in the manual (multiple times actually).

If you want to get even deeper then take a look into Petter optimization book. It’s a must read when you have time but is pretty lengthy.

3 Likes

Definitely giving the manual a deep dive and hopefully will carve out time to read the book you’ve referenced. Thanks for these recommendations!

Simply switching to searching for one datatype and using constraints referencing custom states has improved performance significantly but looking forward to these reads to achieve high performance at scale with sophisticated searches.

Thanks everyone!