Realtime Database vs Firestore: 9 Major Differences

Firestore is much better than the Realtime Database like the black trainer. Period.

When it comes to cloud and database hosting, there are several options available for the developers such as Firebase, Firestore, AWS, Google Cloud and so on. If you are curious about Firebase vs AWS comparison, you can read this Firebase vs AWS article here.

In this article, you’ll come across the major differences that can help you to figure out the better alternative — especially between Firebase and Firestore.

TL;DR

  • Cloud Firestore: It’s a Firebase new database that is used to build mobile apps. It has better scalability than a realtime database. Also, they have faster queries with richer features, etc.

  • Firebase Realtime Database: It’s an older and original database that will give you a low latency solution for mobile apps. It will sync your data instantly.

Now you might be thinking that both databases are good. So which should I go with? You can answer yourself once you know the major differences.




1. Data Model

Doesn’t it sound like the Machine Learning Model? LOL. But it’s not. Sadly!

The good news is that both have NoSQL databases. Find out more:

  • Firebase Real-time Database: In Firebase Real-time Database stores data in a large JSON tree. That’s why small or simple data is easy to store. But complex and hierarchy based data is hard or organized when it’s scaled.

  • Cloud Firestore: In Cloud Firestore, data is stored as a collection of documents. Small data is easy to store in documents that are pretty similar to JSON. On the other hand, Cloud Firestore complex and hierarchy based data is very easy to organize at scale. You can use subcollection in the documents. Cloud Firestore requires less normalization.


2. Real-time and Online Support

Both the database supports offline mode (means support local storage) and supports real-time SDKs.

  • Real-time Database: Offline support only for mobile (Android & iOS) devices.

  • Cloud Firestore: Offline support for mobile (Android & iOS), web clients as well.


3. Presence

It can be very useful to gather the information that your client is online or not.

  • Real-time Database: Real-time database records client connection status and provides us updates whenever the client connection is online or offline.

Cloud Firestore: Not supported natively. But that doesn’t mean you don’t have access to this feature. You can use real-time database support for presence, just syncing cloud Firestore and real-time database with the help of cloud functions.

Related: How to Choose Between Firebase and CometChat Pro


4. Querying

You can sort, retrieve and filter any kind of data from databases through queries.

  • Real-time Database: You can use deep queries. But have some limitations on filtering and sorting the functionalities. You can use filter or sort on a property in your query but can not process both. By default, queries are deep and always return a complete subtree.

  • Cloud Firestore: You can use index queries with good compound filtering and sorting. You can use sorting, combine filtering and chain filter on every property in one single query. Here queries are light; they only return a document in the particular collection or the group of the collection but never return sub collection data. It means that Firestore Queries must return the whole document.


5. Writes and Transactions

  • Real-time Database: Real-time database gives you a basic writes and transactions operation. Like writing data through the update and set operations. Here transaction is on specific data subtree.

  • Cloud Firestore: Cloud Firestore gives you advanced writes and reactions operations like writing data through the update and sets operations and you can use advanced transformation i.e., array and numeric operations, etc. Transactions can automatically write and read data from any part of your database.

6. Reliability and Performance

Reliability & performance are important parts where you can decide which database you want to choose.

  • Real-time Database: It is a single region solution. In a single region, the database is limited to zonal availability. It provides a low latency. I think it’s an ideal option for the apps which use frequent syncing.

  • Cloud Firestore: It is a multi-region solution, which means it scales automatically. Share your data across multiple data centers in separate regions just to make sure scalability is global and provides us strong reliability. It also provides regional and multi-regional configurations in the world.


7. Scalability

  • Real-time Database: In real-time database, the scaling process is not automatic, we have to scale on your own. It scales around 200k connections simultaneously and gives you 1k writes per second in a single database. Real-time database gives you no limit on writes.

  • Cloud Firestore: In the Cloud Firestore Scaling process is automatic. Firebase does it on their own. In Cloud Firestore, it can be scaled over 1 million connections simultaneously and gives you 10k writes per second. And Firebase is going to increase this limit in the future. But the cloud Firestore has a limit on writes to every single document or index also.


8. Security

  • Real-time Database: Authorization and validation are separate. Write and read rules from the mobile SDKs which are secured by Firebase Real-time database rules. You can easily validate the data separately with the valid rules.

  • Cloud Firestore: Authorization and validation are combined. Write and read rules from the mobile SDKs which are secured by Firestore security rules. Here rules can restrict your queries because if a query’s result might be a kind of data that the user doesn’t have access to then the entire query fails.


9. Pricing

You can check out the pricing details from here Spark plan, Blaze plan, Flame plan.

  • Real-time Database: Firebase Real-time database charges only on Storage and bandwidth, which means other things are free. but I think storage and bandwidth charges are a little bit high.

  • Cloud Firestore: Firebase cloud Firestore charges on your operations like read, delete & write and storage and bandwidth charges are low rather than Real-time database.


In simple terms, if you are small scale go with Real-time or if you want to grow big, go with Cloud Firestore.

Which Is the Winner?

I recommend you to go with Cloud Firestore.

The reason is pretty simple because it’s a new database and it is recommended by the Firebase team.

Moreover, Firestore gives you additional functionality, better performance, more robust security rules, and most importantly, it’s scalable.



Have fun and use your code for good. 🙏

At the end, please Subscribe to my newsletter DroidUp to get more tutorials and tips on Android development directly in your inbox.


If you liked this article, you can read my new articles below:


profile card
Wajahat Karim
🌍 Making the world a better place, one app at a time.
🔥 Google Developer Expert (GDE) in Android . 📱 Professional Android Developer with ~10 years experience. 💻 Creator of various Open Source libraries on Android . 📝 Author of two technical books and 100+ articles on Android. 🎤 A passionate Public Speaker giving talks all over the world.
Author's picture

Wajahat Karim

🔥 Google Dev Expert (GDE) in Android .
📱 Android Dev. 💻 Open Source Contributor . 📝 Technical Writer . 🎤 Public Speaker

Senior Android Developer

Karachi, Pakistan