Subhan
Subhan

Reputation: 1634

Google Cloud Firestore documents limit

I've been working with Google Cloud Firestore. I'm about to import 13000+ records from a CSV to the firestore back-end. I'll be using this collection for look up and auto-completion purposes.

I'm curious and concerned to know if this is a good idea. Also, I'm looking for some suggestions on what techniques should I be using to make retrieval of this this data as efficient as possible. I'm working with Angular 5 and using AngularFire2 to connect with Firestore.

The document itself is really small such as:

{
  address: {
    state: "NSW"
    street: "19 XYZ Road"
    suburb: "Darling Point"
  },
  user: {
    name: "ABC",
    company: "Property Management Company"
  }
  file_no: "AB996"
}

Most of the searching would be based on file_no property of the document.

Update

I just imported all 13k+ records to Firestore. It is really efficient. However, I have one issue. After importing the records, I'm getting the message on my Firestore console that my daily limit for Read Operations is reached (0.05 of 0.05 Million Ops). I just wrote data and displayed those records in a Data Table. I used the following query:

this.propertyService
      .getSnapshotChanges()
      .subscribe(properties => {
        this.properties = properties;
        this.loadingIndicator = false;
      });


getSnapshotChanges(): Observable < any > {
  return this.afs.collection(this.propertiesCollection).snapshotChanges()
    .map((actions) => {
      return actions.map((snapshot) => {
        const data = snapshot.payload.doc.data();
        data.id = snapshot.payload.doc.id;
        return data;
      });
    });
}

How dos this makes my reading limit exceed?

Upvotes: 0

Views: 1477

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598718

The number of documents in a collection is of no consequence when you use Cloud Firestore. That's actually one of its bigger perks: no matter how many documents are in a collection, the queries will take the same amount of time.

Say you add 130 document and (for sake of example) it takes 1 second to get 10 documents out of it. That's the performance you'll get no matter how many documents are in the collection. So with 1300 documents it will also take 1 second, with 13K it will take 1 second, and with 13M, it will also take 1 second.

The problem more developers run into is to make their use-cases fit within the API of Firestore. For example: the only way to search for strings is with a so-called prefix match, there is no support for full-text search. This means that you can search for Prop* and find Property Management Company, but not for *Man* to find it.

Upvotes: 2

Related Questions