Don-Ricardo
Don-Ricardo

Reputation: 213

Firestore database reads are increasing without even running the application

I have been noticing some increase in the amount of reads in the firestore. I am testing my application on localhost.

Today I decided to have a closer look at the amount of reads and started from zero. I waited around 3 minutes without even running my application or performing any read operation, and my number of reads went up to 210, and 2 writes. Now that must be pretty weird, knowing that the application wasn't even running and it was all zero when I started.

I tried to avoid the onvalueChanges() and snapshotChanges() since they generate a lot of read.

Below is the service that I call in the home page.

Any one has an idea on what's going on, and would like to share?

Thanks in advance.

 export class CatService {
 lastVisibleCat: any;
 cats = [];
 fecha = new Date().setHours(23, 59, 5, 9);
 todaysDate = new Date(this.fecha);


   constructor(public afs: AngularFirestore) {
  }

getCats() {
const reference = this.afs.collection('Cats');
const query1 = reference.ref.where('timeStampEndDate', '>=', 
this.todaysDate);
return query1.get().then(snapShot => {
  snapShot.forEach(cat => {
    this.cats.push({ ...cat.data(), id: cat.id });
  });
  return this.cats;
});
}

  }

Upvotes: 4

Views: 1370

Answers (1)

rockwotj
rockwotj

Reputation: 473

A couple of things could be at play here:

  • Read counts are not real time, so the data could be coming in delayed
  • Reads in the Firebase Console also count towards billed operations in terms of read counts

Upvotes: 2

Related Questions