0

my homepage uses 3 different listview.builder to display data from futures

 getFuture() async { setState(() { Future1 = FirebaseFirestore.instance.collection("Posts").orderBy(sortBy, descending: descending).limit(20).get(); Future2 = FirebaseFirestore.instance.collection("Posts").orderBy("source", descending: descending).limit(10).get(); Future3 = FirebaseFirestore.instance.collection("Posts").orderBy("date_sort", descending: descending).limit(10).get(); }); } 

i also implemented lazyloading for Future1:

 getDocumentsNext(String sortBy, bool descending) async { var lastVisible = collectionState!.docs[collectionState!.docs.length-1]; print('listDocument legnth: ${collectionState!.size} last: $lastVisible'); collection = FirebaseFirestore.instance.collection('Posts').orderBy(sortBy, descending: descending).startAfterDocument(lastVisible).limit(25).get(); fetchDocuments(collection!); } fetchDocuments(Future collection){ collection.then((value) { collectionState = value; value.docs.forEach((element) { setState(() { listDocument.add((element.data())); }); }); }); } 

so only Future1 will add more doc to the list upon scrolling vertically, while Future2 & Future3 will remain unchanged and display 10 items only.

however when i try to scroll the listview.builder, for example 5 times which i got 5 x 25 = 125 of docs loaded ... but my firebase console is showing 1k+ of reads, sometimes can go up to 4k-5k reads if i scroll around 10 times...

how can this possible if the size of my entire dataset is just 3k of docs, and i just loaded less than 500 of doc but getting 1k+ of reads sometimes even more than the size of my dataset ?

==========================================================

EDIT: how to avoid extra reads on firebase console ?

5
  • You will need to consider that usage of the Firestore console incurs reads as well. And if you leave the console open on a busy collection, it will accrue more reads as it reflects the contents in real time. Commented Jul 30, 2022 at 15:51
  • if i have an extremely large dataset, like 10 millions of docs... whenever i use the console that would incur 10mil of reads ?? how can i maintain the console if thats the case ... Commented Jul 30, 2022 at 16:37
  • No, that would make the console unusable. Notice how the data fills lazily in as you scroll down the list of documents. Commented Jul 30, 2022 at 17:40
  • is there any suggested way to avoid reads on console? Commented Jul 30, 2022 at 18:07
  • There is only one way: don't open it. Commented Jul 30, 2022 at 18:32

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.