Quick verdict
Choose Firebase (Cloud Firestore) if you are building a mobile or web app whose screens read predictable sets of documents, you want clients to read and write the database directly under Security Rules, and offline caching with realtime updates matters more than complex queries. Choose PostgreSQL if your data is relational, you need joins, constraints, grouped reporting or ad hoc SQL, or you want a database you can move between hosts. If you want PostgreSQL but also Firebase-style auth, storage and client libraries, the question becomes a platform choice: see Supabase vs Firebase.
Firebase is Google's app development platform, and this page is about its databases. Cloud Firestore describes itself as a NoSQL, document-oriented database: documents of fields, grouped into collections, with optional subcollections. It comes in a Standard edition and an Enterprise edition; Enterprise adds Pipeline operations, optional indexes, text search and a MongoDB-compatible API. The Realtime Database is Firebase's original database, which stores data as one JSON tree; Google labels Firestore as the preferred choice for new projects. Firebase also offers SQL Connect (formerly Data Connect), which runs on Cloud SQL for PostgreSQL and is covered below.
PostgreSQL is an open source object-relational database under the PostgreSQL Licence. It is software, not a service: you run it on your own servers or containers, or rent it as a managed service such as Cloud SQL for PostgreSQL, AlloyDB, Amazon RDS, Supabase or Neon. The current stable release on postgresql.org is 18.6.
The two differ in kind as well as model. Firestore is a serverless database designed to be called from client apps; PostgreSQL is a database server that applications reach through a backend or an API layer. This page compares them as databases. For the backend platform comparison (auth, storage, functions) see Supabase vs Firebase, and for the modelling question see Relational vs Document Database.
Side by side
| Aspect | Firebase | PostgreSQL |
|---|---|---|
| What it is | Serverless Google NoSQL databases (Firestore, Realtime Database) | Open source relational database server; self-managed or managed by many providers |
| Data model | Firestore: documents in collections and subcollections; RTDB: one JSON tree | Tables with declared columns and constraints; jsonb for flexible data |
| Queries | SDK queries with filters and ordering; no joins; count(), sum(), average() aggregations |
Full SQL: joins, GROUP BY, window functions, subqueries |
| Who connects | Mobile and web clients directly, through Firebase SDKs | Your backend or an API layer; clients do not usually connect directly |
| Access control | Firebase Security Rules for client SDKs; IAM for server libraries | Roles, privileges and row security policies (CREATE POLICY) |
| Realtime and offline | Realtime listeners; offline persistence on by default on Android and Apple | LISTEN/NOTIFY and logical replication on the server; no client offline sync |
| Transactions | Atomic transactions and batched writes; optimistic concurrency; transactions fail offline | ACID transactions with MVCC and configurable isolation up to serializable |
| Scaling | Automatic; no servers to size | You size the server, add replicas and connection pooling (or let a managed service help) |
| Pricing model | Free Spark quotas, then per document read, write and delete plus storage | No licence fee; pay for servers or a managed instance |
| Main trade-off | Client sync and zero operations, but limited queries, per-read billing and Google-only hosting | SQL, integrity and portability, but you build the API and run or rent the server |
Key differences
Data model and querying
Firestore is schemaless: Google's data model page says you have complete freedom over the fields and types in each document. Queries filter and order documents in one collection (or a collection group). In Standard edition, indexes are required for every query; single-field indexes are created automatically and composite indexes must be defined. The documented limits include up to 30 equality clauses combined in an in filter and up to 10 in a not-in filter. There are no joins, so related data is denormalised into documents or fetched with extra reads.
Aggregation in Standard edition means count(), sum() and average() over the results of a query, which Google notes saves billed reads compared with downloading the documents. A "revenue per country" report therefore needs one aggregation query per country or totals you maintain yourself. Enterprise edition's Pipeline operations add further aggregation and string-matching operators.
// Firestore (modular web SDK): one figure for one filter
import { collection, query, where, getAggregateFromServer,
count, sum } from "firebase/firestore";
const q = query(collection(db, "orders"),
where("country", "==", "GB"),
where("status", "==", "shipped"));
const snap = await getAggregateFromServer(q, {
orders: count(),
revenue: sum("total")
});
console.log(snap.data().orders, snap.data().revenue);-- PostgreSQL: every country at once, joining customers to orders
SELECT c.country,
count(*) AS orders,
sum(o.total) AS revenue
FROM orders o
JOIN customers c ON c.customer_id = o.customer_id
WHERE o.status = 'shipped'
GROUP BY c.country
ORDER BY revenue DESC;In our assessment this is the decisive difference for most teams: Firestore works well when each screen maps to a known query, while PostgreSQL also answers the questions you did not plan, which is where reporting and back-office work usually go. See SQL vs NoSQL for the wider trade-off.
Who talks to the database, and how it is secured
Firestore is designed to be called from the app itself. Google's documentation states that every request from a Firestore mobile or web client library is evaluated against your Security Rules before any data is read or written, while server client libraries bypass Security Rules and authenticate with Google Application Default Credentials and IAM. Your rules are therefore the security boundary for client access, and they must be written and tested as carefully as server code.
PostgreSQL expects connections from trusted servers. A typical design puts an API between the app and the database, which holds credentials and enforces access. PostgreSQL also offers row security policies: once row level security is enabled on a table, the documentation describes a default-deny behaviour when no policy applies, and policies decide which rows each role can see or change. API layers such as PostgREST (used by Supabase) rely on these policies to expose PostgreSQL more directly.
-- PostgreSQL: each signed-in role sees only its own orders
ALTER TABLE orders ENABLE ROW LEVEL SECURITY;
CREATE POLICY own_orders ON orders
FOR SELECT
USING (owner_name = current_user); Realtime updates and offline use
Firestore clients can attach realtime listeners to a document or query and are notified when the results change. Offline persistence is enabled by default on Android and Apple platforms and disabled by default on the web; when enabled, the SDK caches the data the app is actively using and syncs local changes when the device reconnects. Google documents some limits: Pipeline operations do not work offline, and transactions fail when the client is offline. The Realtime Database also syncs to clients, with offline support on Apple and Android only.
PostgreSQL has server-side building blocks rather than client sync: LISTEN and NOTIFY for notifications between sessions, and logical replication for streaming row changes. Pushing changes to browsers or phones, and letting them work offline, needs additional software (for example Supabase Realtime for change notifications, or a third-party sync layer). If offline-first mobile behaviour is a core requirement, Firestore provides it out of the box.
Consistency, transactions and limits
Firestore replicates data synchronously across zones using Paxos, and Google documents that reads return the latest version of the data. Transactions read and then write, never apply partially, and are retried automatically on conflict (optimistic concurrency); batched writes group several writes atomically without reads. Documented limits include a maximum document size of 1 MiB, nesting of up to 20 levels in maps and arrays, and 40,000 index entries per document.
PostgreSQL runs every statement in an ACID transaction under multiversion concurrency control, offers isolation levels up to serializable, and enforces types, NOT NULL, CHECK, unique and foreign key constraints, so invalid or orphaned data is rejected by the database rather than by application code or rules.
Scaling and operations
Firestore needs no capacity planning: Google's comparison page says it scales automatically with no limit on concurrent connections. The Realtime Database is different: Google states it scales to around 200,000 concurrent connections and 1,000 writes per second in a single database, beyond which you shard across several databases. Firestore is available only as a Google service, with no self-hosted version.
PostgreSQL scales up on one primary, adds read replicas through streaming replication, and scales out through extensions such as Citus. Each client connection is a server process, so applications with many short-lived connections, such as serverless functions, usually add a connection pooler. Managed services take over backups, patching and failover, and because PostgreSQL is the same engine everywhere you can change provider; see Supabase vs Neon, Supabase vs AWS RDS and Google Cloud SQL vs AlloyDB.
PostgreSQL inside Firebase: SQL Connect
If you want Firebase's SDKs and tooling with a relational database, Firebase SQL Connect (renamed from Data Connect, with unchanged APIs) is built on Cloud SQL for PostgreSQL. You define a schema and operations in GraphQL, Firebase generates typed SDKs for Android (Kotlin), iOS, Flutter and the web, and the documentation also covers implementing operations in native SQL. This gives a real PostgreSQL database under a Firebase project, but clients use generated operations rather than ad hoc queries. Firestore Enterprise edition's MongoDB compatibility is a separate option for teams with MongoDB code and tools.
Pricing and licensing
Cloud Firestore. Listed in the Firebase documentation and pricing page in October 2026. The no-cost quota for Standard edition is 1 GiB stored, 50,000 document reads, 20,000 writes and 20,000 deletes per day, and 10 GiB of outbound transfer per month, for one database per project. Beyond that, on the pay-as-you-go Blaze plan, Firestore charges for documents and index entries read to satisfy a query, for each write and delete, and for stored data, at prices that vary by location (published on the Google Cloud Firestore pricing page). Enterprise edition is priced separately. Because billing follows operations, the cost of a screen depends on how many documents it reads.
Firebase SQL Connect. According to Firebase's SQL Connect pricing page, the Blaze plan includes 250,000 operations per month at no cost, then USD 0.90 per million operations, plus the underlying Cloud SQL instance, which Firebase says starts at USD 9.37 per month depending on region and configuration. Qualifying accounts get a three-month no-cost Cloud SQL trial.
PostgreSQL. The software is free under the PostgreSQL Licence. You pay for the servers you run it on or for a managed service, which providers price by instance size, storage, I/O and region; there is no single list price to quote.
Pricing checked on the vendors' official pages on 7 October 2026. Prices change; confirm before buying.
Where each one leads
Firebase strengths
- Mobile and web clients read and write directly, with Security Rules as the access layer
- Realtime listeners and offline persistence built into the SDKs
- Serverless: no instances, connections or failover to manage
- Strongly consistent reads with synchronous replication across zones
- Free Spark quotas cover small apps without a payment method
PostgreSQL strengths
- Full SQL with joins, GROUP BY and window functions for any question
- Constraints and foreign keys keep data valid in the database
- Open source under the PostgreSQL Licence, with many managed providers and no lock-in
- Instance-based cost does not grow with every read
- Row security policies can enforce per-user access in the database
Limitations
Firebase limitations
- No joins and limited aggregation in Standard edition; reporting needs extra queries, precomputed totals or an export
- Per-operation billing makes cost depend on read patterns
- Google-only service with no self-hosted version; leaving means rewriting queries and rules
- Documents are limited to 1 MiB, and Standard edition queries need indexes
- Security Rules are the boundary for client access and are easy to get wrong
PostgreSQL limitations
- You must build or adopt an API layer; apps do not normally connect directly
- No built-in client realtime or offline sync
- You size, operate and pay for a server (or a managed instance) even when idle
- Many concurrent connections need a pooler
When to choose each
Choose Firebase if
- A mobile app must work offline and sync when the device reconnects
- Screens map to a known set of document queries with realtime updates
- You want no database server to run and accept per-operation billing
- You already use Firebase Authentication and other Google Cloud services
Choose PostgreSQL if
- Your data is relational and you need joins, constraints and transactions
- You need reporting, analytics or ad hoc queries over application data
- Portability matters and you want to be able to change hosting provider
- Your backend already has an API layer, or you use one built on PostgreSQL
- Predictable instance-based cost suits you better than per-read billing
When neither is right
- You want PostgreSQL with built-in auth, storage and client libraries: compare the platforms in Supabase vs Firebase and see Firebase alternatives.
- You want a document database you can self-host or run on several clouds: see MongoDB vs PostgreSQL.
- You are on AWS and want a serverless key-value store: see DynamoDB vs PostgreSQL.
- An app that needs a local database on the device: an embedded database such as SQLite fits; see SQLite vs PostgreSQL.
Final recommendation
In our view, PostgreSQL is the better database when the data is relational or will feed reporting, because SQL, constraints and portability outlast any one app. Cloud Firestore is the better fit for client-centric mobile and web apps with document-shaped data, where direct SDK access, realtime listeners and offline caching save building a backend, provided you design for its query limits and per-read billing. If you need both relational data and Firebase-style client features, look at Firebase SQL Connect or at PostgreSQL-based platforms such as Supabase.
Frequently asked questions
Is Firebase a database?
Firebase is a platform that includes two NoSQL databases, Cloud Firestore and the Realtime Database, alongside authentication, storage, functions and other services. Firebase SQL Connect adds a PostgreSQL database through Cloud SQL.
Can Firestore do joins?
No. Firestore queries read from one collection or collection group. Related data is usually denormalised into documents or fetched with additional reads. Firestore Enterprise edition adds Pipeline operations with more query operators, and SQL Connect offers PostgreSQL for relational data inside Firebase.
Can I use PostgreSQL with Firebase?
Yes, through Firebase SQL Connect, which runs on Cloud SQL for PostgreSQL. You define the schema and operations in GraphQL and use generated SDKs, and the documentation also covers native SQL operations. You can also use any PostgreSQL service from Cloud Functions.
Should I use Firestore or the Realtime Database?
Google marks Cloud Firestore as the preferred option for new projects: it has richer queries, offline support on the web as well as mobile, and automatic scaling. The Realtime Database stores one JSON tree, scales to about 200,000 connections per database and charges for bandwidth and storage rather than operations.
Is Firestore free?
Within the Spark plan quotas (1 GiB stored, 50,000 reads, 20,000 writes and 20,000 deletes per day for Standard edition). Beyond that, the Blaze plan bills per operation and stored data. See the dated pricing section above.
Sources
- Cloud Firestore documentation
- Cloud Firestore: Data model
- Cloud Firestore: Editions
- Cloud Firestore: Simple and compound queries
- Cloud Firestore: Aggregation queries
- Cloud Firestore: Transactions and batched writes
- Cloud Firestore: Access data offline
- Cloud Firestore: Security Rules
- Cloud Firestore: Understand reads and writes at scale
- Cloud Firestore: Usage and limits
- Cloud Firestore: Billing
- Firebase: Choose a database (Realtime Database vs Cloud Firestore)
- Firebase SQL Connect documentation
- Firebase SQL Connect pricing
- Firebase pricing
- PostgreSQL documentation: Row security policies
- PostgreSQL documentation: NOTIFY
- PostgreSQL documentation: Transaction isolation
- PostgreSQL Licence
Checked October 2026.
How we research comparisons: our editorial method.