-1

I am using Firestore to store my data. Now I want to fetch perticular collection from it. I am using FirestorePagingAdapter to do this.

Scenario: I am querying Firestore to fetch all documents from perticular collection, lets say posts(collection) contain 100 documents, and FirestorePagingAdapter configured as below

-setPrefetchDistance(2)
-setInitialLoadSizeHint(10)
-setPageSize(10)

Now my doubt is will FirestorePagingAdapter fetch all documents at once (means all 100 doc once) then then apply paging or query Firestore according to page size (10 at a time), and when reaches to bottom, will fetch next 10 doc?

Basically I want to reduce read operations in Firestore.

Please help me here.

Marvin Klar
  • 1,869
  • 3
  • 14
  • 32
Shendre Kiran
  • 157
  • 2
  • 8

1 Answers1

1

will FirestorePagingAdapter fetch all documents at once (means all 100 doc once) then then apply paging

Definitely not.

query Firestore according to page size (10 at a time), and when reaches to bottom, will fetch next 10 doc?

Definitely yes. So first time you are billed with 10 read operations and once you load 10 more items, you are billed with 10 more read operations. So if you load only two parts of your items (20 items) you'll be billed with 20 read operation and not with 100.

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193