0

I'm creating an ecommerce app that has 100+ products. I want to show only 4 featured products on the homescreen.

Now, my question is, whether should I create a separate collection for featured products or use the same collection?
I know that even if I use a same collection for both, featured and simple products, I can show any/both of them by using if/else but if I want to show only 4 products, and if I use .isEqual method of Firebase(code is given below), will it take the same time as fetching 100 products take? Or will it take the time to fetch only 4 products?

Here is the code (Flutter):

final snapshot = await _db.collection('EProducts').where('isFeatured', isEqualTo: true).limit(4).get();
2
  • 3
    Race your horses
    – Filburt
    Commented 20 hours ago
  • @Aabis: Loading a list of documents from Firestore always works the same way: Firestore looks up the matching documents in an index, and then returns each of those documents. By far and large the performance comes from that latter step: the number of documents it has to returns. So you're better off using a query here. Commented 16 hours ago

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.