Forum Academy Marketplace Showcase Pricing Features

Database Optimization - Search or Link

I have a type “product” and another type “custom product”


The custom product is inside an RG that is inside an RG for products.
My team uses search(with constraints for that user) for finding the exact “products” and his “custom products”

Two options
Over time the “custom product” will have more than 30.000 entrys.
1 - Is it good for a team with 10 people(can increase) doing this search 40 times a day each?
or
2 - it will be better to link the “custom product” inside a user “custom products list” so that the search will be done on the items of that user.

Do you think it would be worth implementing the second option? Or it wouldn’t even make a difference because the bubble system would already do this optimization because of the restrictions I used(I don’t know if that’s how it works, it’s an assumption)?

Hi!

Goodness no, the last thing you want to is to have a giant list in one field of a data type because Bubble loads all fields of a match if it has to refer to even one field (so do any plugins, it’s just how Bubble search works). Better to have a “user” field for each custom product.

And you sir are correct that Bubble has greatly optimized how searches work in their backend and hence the importance of having good search constraints. This is because any constraints in a Search For is done backend and any :filtered operators are performed client side.

The problem will be striking a balance between backend and clientside if, like in my app, you need to further process those search results.

1 Like

One question I have is if you did a store a massive list under a data type, if you reference the parent Thing, it doesn’t necessarily need to retrieve the giant list right? It’s only when you need one item from the list it needs to get the entire list?

I may or may not have a thing with 10K items in a list field :flushed:

Unless you have a privacy rule attached to that particular field, yes Bubble will load all data of each item of that data type that matches your initial search constraints. You can see this when you check your page’s network usage in Chrome’s inspect tools.

1 Like

In my particular case I have a list of 10K items under a Thing, but when I have a page for the Thing it doesn’t seem like it downloads the 10K items unless I show a repeating group of that list. :thinking:
Unless it’s still downloading all the data but showing it takes even more data?

Yep, so what’s happening is in 1 item of that data type (which is matched using your search criterias), Bubble loads everything in all fields that pass your data type’s privacy rule and in this case your field containing 10k list of things passes.

Here’s where Bubble is smart, it doesn’t load all the things in that field immediately but instead something like pointers to them (you can still do a :count without Bubble loading all fields in that of items in the list).

And just as you mentioned, Bubble will only load the fields of those items in the list when you have an element referring to any one of their fields (in your case the repeating group).

It’s still safe if you are only matching searches to retrieve a handful of the big data types but it’s always a good practice to keep your database as relational as possible and plan ahead for how you want searches to work for each data type.

1 Like

Would have some amount from which it would be worth creating a link with another related TYPE?
For example up to 1000 items in the database a search with constraint is enough
from 10,000 it would be better to link with something else like the user and search from that

I think a question is how related are all the items. If it’s a short list of phone numbers under a contact, you could just keep the list under the specific contact. If someone is viewing a contact card they might want to see all the phone number so they know which one to call.

In my example of 10,000 items under one list, in my specific use-case all 10K items will always need to be referenced at the same time. It’s a giant list that shows up on a PDF report, and they always need to be shown. So I took the guess that it’s faster to tell Bubble “Show me these 10K items that I’ve already listed for you” vs “Do a search for these 10K things out of the 500K items, and show me all 10K at once”

If your specific case it sounds like a search would make more sense, because a user might want to search for a product with a constraint, and not necessarily see the whole list all at once?