title: Most efficient approach to count documents in one or more Firestore collection(s)
body: <p>I'm developing a delivery application, I would like to get the counts for the admin to analyze (number of orders, number orders paid with visa, etc...).
  I tried to read all the documents and get snapshot count but I figured out it will cost me a lot of reads and if the dataset is large it will slow down my application.
  So I created a collection called counts, and I created a cloud function to listen for document create and increment the count field in users document in the counts' collection, it works perfectly but I would like to know if it will cost me a fortune and if there is a better solution.
  note: I will listen to 5+ collections</p>
  <p>here is my function:</p>
  <pre class="lang-js prettyprint-override"><code>const functions = require('firebase-functions');
  
  // The Firebase Admin SDK to access Firestore.
  const admin = require('firebase-admin');
  admin.initializeApp();
  
      var firestore = admin.firestore();
   // Listens for any document created in the users collection
  exports.createUser = functions.firestore
      .document('users/{userId}')
      .onCreate((snap, context) =&gt; {
   firestore.collection('counts').doc('users').update({ count: admin.firestore.FieldValue.increment(1) })
  return 'done';
  });
  </code></pre>