The quantity of documents queried does not align with the number of data counts retrieved from Firestore

Facing an issue with calculating the Firestore read count as it keeps increasing rapidly even with only around 15 user documents. The count surges by 100 with each page reload and sometimes increases on its own without any action from me. Could this be due to a subscription behavior causing data reads to refresh periodically? (I've come across suggestions to use "once" for one-time data extraction).

Below is the TypeScript code snippet:

// All buddy users from Firebase
private usersCollection: AngularFirestoreCollection<Profile>;
users: Observable<Profile[]>;
usersFirebase: Profile[] = [];

getUserDataFromFirebase() {
this.isImageLoading = false;
this.users.subscribe(async results => {
    var ref;
    for(let result of results) {
      if(result.imageName) {
        ref = this.store.ref('images/' + result.userId + '/profiles/' + result.imageName);
      } else {
        // Get default image if image does not exist.
        ref = this.store.ref('images/ironman.jpg');
      }

      await ref.getDownloadURL().toPromise().then(urlString => {
        result.profileURL = urlString;
        // Convert availability date from timestamp to date format
        try {
          result.availability = this.datePipe.transform(result.availability.toDate(), 'yyyy-MM-dd');
        } catch (error) {}
        result.flip = 'inactive';

        if(result.identity == 'Tenant')
        {
          this.usersFirebase.push(result);
        }
        return new Promise((resolve, reject) => {
            resolve();
          })
      });
    }
    console.log(this.usersFirebase);
  });
}

How exactly does the firestore read count function? Is the increment based on document queries and does it continue querying itself after a certain period? Firestore read count exceeds number of user documents

Answer №1

The focus of read counts is on the number of documents retrieved.

Let's consider these four scenarios:

  • If you have a collection of 10 users and you execute a collection("users").get() call, you will receive 10 employee documents and incur 10 reads.
  • Having a collection of 10,000 users and running a collection("users").get() call will result in retrieving 10,000 users and being charged for 10,000 reads.
  • For a collection of 10,000 employees, using
    collection("users").get().limit(10)
    will give you 10 users and cost you 10 reads.
  • In a collection of 10,000 users with 15 named "Carl," executing
    collection("users").where("first_name", "==", "Carl")
    will return 4 users and require 15 reads.

Conversely, if you are monitoring the entire collection users without any where() or orderBy() clauses and have an active onSnapshot() listener, you will be billed for a document read operation each time a new document is added, changed, or deleted in the collection users.

It may be worth reviewing your workflow to ensure that other processes aren't impacting the read operations in your collection.

Furthermore, keep in mind that the reported read ops may not align perfectly with billing and quota usage. There is a feature request related to this issue in the Public Issue Tracker regarding reads on Firestore: here. You can "star" it and adjust the notifications to stay updated. Additionally, feel free to create a new issue if needed.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Vue3 and Ionic combined to create a Component that became a reactive object in Vue

Vue is issuing a warning about receiving a Component as a reactive object, which can cause unnecessary performance overhead. The warning suggests using markRaw or shallowRef instead of ref to avoid this issue. However, in my code, I am not explicitly using ...

Error alert - Property 'url' is not defined and cannot be read

I am currently working on developing my app using ionic version 3. To fetch videos from my Youtube playlist, I am utilizing the Youtube REST API. However, I have encountered an issue where the video thumbnails are not showing up in the app and I keep recei ...

Rxjs: Making recursive HTTP requests with a condition-based approach

To obtain a list of records, I use the following command to retrieve a set number of records. For example, in the code snippet below, it fetches 100 records by passing the pageIndex value and increasing it with each request to get the next 100 records: thi ...

Guide on updating a property key in Firebase real-time database with Angular 7

Is it possible to modify the key of a property in my firebase database that I have been struggling with? ...

Changing the size of a div component using Angular 6

Currently, I am working on implementing Angular's element resize feature. I am utilizing this library: https://github.com/mattlewis92/angular-resizable-element Here is my custom module: import { ResizableModule } from 'angular-resizable-elemen ...

The term 'EmployeeContext' is being utilized as a namespace in this scenario, although it actually pertains to a type.ts(2702)

<EmployeeContext.Provider> value={addEmployee, DefaultData, sortedEmployees, deleteEmployee, updateEmployee} {props.children}; </EmployeeContext.Provider> I am currently facing an issue mentioned in the title. Could anyone lend a hand? ...

What is the process to activate a function within a component once a service method has been run?

I'm currently working on a chart configuration using amCharts, where an eventListener is registered for the bullets. This event listener then triggers another function in my chart service. My goal is to activate a method in my component as soon as th ...

Guide on filtering FlatList Data in react native by selecting multiple categories from an array

User Interface Image I am looking to implement a filter functionality in the FlatList data based on top categories, where the filter button allows for multiple selections. The FlatList data is stored in the HotelData array, and the categories are also re ...

When attempting to launch my Next.js project on Vercel, an issue arises with the message: "Encountering a FirebaseError: Firebase: Error (auth/invalid-api-key)."

I encountered a wall of errors during the build process: (node:748) UnhandledPromiseRejectionWarning: FirebaseError: Firebase: Error (auth/invalid-api-key). at createErrorInternal (file:///vercel/path0/node_modules/@firebase/auth/dist/node-esm/index-c3 ...

Ways to set a default selection for an md-radio-button in md-radio-groups

My button group consists of 3 radio buttons for filtering data, and I would like to have a specific button selected by default when the page loads. Below is the code snippet: <md-radio-group ng-model="status" aria-label="filter" ng-model="status" name ...

Guide to implementing a Page Object Model for improved debugging of Protractor tests

Introduction I am on a mission to streamline my e2e testing code using the Page Object Model for easier maintenance and debugging. My Approach When embarking on creating end-to-end tests with Protractor, I follow these steps to implement the Page Object ...

Having some issues with validating numbers in typescript

When implementing react hook form in my React app, I encountered an issue while validating specific fields and had to add some conditions to the schema. yup .object({ test1: yup.number().when('test2', (test2: number, schema: yup.NumberSchem ...

ERROR: The use of @xenova/transformers for importing requires ESM

When working with my Node.js application, I usually start by importing the necessary modules like this: import { AutoModel, AutoTokenizer } from '@xenova/transformers'; Afterwards, I utilize them in my code as shown below: const tokenizer = awai ...

When using `onClick` in React, the old state value is not captured even though it may appear to be

In order to enhance the modularity and generality of my tabs and tab slots, I have developed a somewhat intricate setup. To achieve this, I opted to create a context and provider that expose methods for manipulating tabs and slots (where slots represent wh ...

How can you establish a TypeScript project that employs classes shared by both client and server applications?

I am working on a project that consists of two components: ServerApp (developed with nodejs using NTVS) and BrowserApp (an Html Typescript application). My goal is to share classes between both projects and have immediate intellisense support. Can you pr ...

Issues related to .maps and the use of import 'rxjs/add/operator/map';

Having an issue with Angular 4 and rxjs/add/operator/map. Even after importing rxjs/add/operator/map, I am unable to use .map. Visual Basics keeps displaying two error messages: message: 'Declaration or statement expected.' message: 'Cannot ...

Discover the magic of observing prop changes in Vue Composition API / Vue 3!

Exploring the Vue Composition API RFC Reference site, it's easy to find various uses of the watch module, but there is a lack of examples on how to watch component props. This crucial information is not highlighted on the main page of Vue Composition ...

Logging out Firebase Auth user upon every page refresh in React

Whenever the page is reloaded, the user is taken back to the login screen even after authentication. I have implemented the onAuthStateChanged listener, but upon refreshing the page it seems like there was no authenticated user in the first place. cons ...

"An error occurred: Uncaught SyntaxError - The import statement can only be used within a module. Including a TypeScript file into a

I need to integrate an Angular 10 TypeScript service into a jQuery file, but I am facing an issue. When I try to import the TypeScript service file into my jQuery file, I encounter the following error: Uncaught SyntaxError: Cannot use import statement outs ...

Observable subscription not updating HTML with changes

My challenge is passing an object to the Object Model using a shared service to an already loaded component. Even though I receive data after subscribing, it does not reflect in the HTML view. <div *ngFor="let emp of emps" class="card&q ...