Detailed comparison of PostgreSQL, MongoDB, and SQLite for Pangolin metadata storage.
| Feature | PostgreSQL | MongoDB | SQLite |
|---|---|---|---|
| Type | Relational (SQL) | Document (NoSQL) | Relational (SQL) |
| Setup | Medium | Medium | None |
| Production Ready | ✅ Yes | ✅ Yes | ✅ Yes (small scale) |
| Persistence | ❌ Catalog: No / ✅ Data: Yes | ✅ Yes | ✅ Yes |
| Scalability | Vertical | Horizontal | Single machine |
| Concurrent Writes | High | Very High | Low |
| Concurrent Reads | Very High | Very High | Very High |
| ACID | ✅ Full | ✅ Full | ✅ Full |
| Transactions | ✅ Yes | ✅ Yes | ✅ Yes |
| Foreign Keys | ✅ Yes | ❌ No | ✅ Yes |
| Indexes | ✅ Advanced | ✅ Advanced | ✅ Basic |
| Full-Text Search | ✅ Built-in | ✅ Built-in | ✅ FTS5 |
| JSON Support | ✅ JSONB | ✅ Native | ✅ JSON1 |
| Branch Isolation | ✅ Yes | ✅ Yes (Native) | ✅ Yes |
| Replication | ✅ Built-in | ✅ Built-in | ❌ Manual |
| Sharding | ✅ Built-in | ❌ No | |
| Backup | ✅ pg_dump | ✅ mongodump | ✅ File copy |
| Point-in-Time Recovery | ✅ Yes | ✅ Yes (Atlas) | ❌ No |
| Cloud Managed | ✅ RDS, Azure, GCP | ✅ Atlas, Azure, GCP | ❌ No |
| Resource Usage | Medium | Medium | Very Low |
| Memory Footprint | ~100MB+ | ~100MB+ | ~10MB |
| Disk Space | Medium | Medium | Low |
| Network Required | ✅ Yes | ✅ Yes | ❌ No |
| Operation | PostgreSQL | MongoDB | SQLite |
|---|---|---|---|
| Single row by ID | Excellent | Excellent | Excellent |
| Range queries | Excellent | Excellent | Excellent |
| Complex joins | Excellent | Good | Good |
| Aggregations | Excellent | Excellent | Good |
| Full table scan | Good | Good | Excellent (small DBs) |
| Operation | PostgreSQL | MongoDB | SQLite |
|---|---|---|---|
| Single insert | Excellent | Excellent | Excellent |
| Bulk insert | Excellent | Excellent | Good |
| Concurrent writes | Excellent | Excellent | Poor |
| Updates | Excellent | Excellent | Good |
| Deletes | Excellent | Excellent | Good |
- Vertical Scaling: Scale up to very large servers (1TB+ RAM)
- Read Replicas: Multiple read-only replicas
- Connection Pooling: PgBouncer for thousands of connections
- Partitioning: Table partitioning for large datasets
- Limitations: Single-master writes
- Horizontal Scaling: Shard across multiple servers
- Replica Sets: 3-50 members
- Auto-Sharding: Automatic data distribution
- Geographic Distribution: Multi-region clusters
- Limitations: Complexity increases with sharding
- Single Machine: Limited to one server
- File Size: Tested up to 281TB (theoretical)
- Practical Limit: ~1TB with good performance
- Limitations: No built-in replication or clustering
| Backend | Setup Cost | Ongoing Cost | Complexity |
|---|---|---|---|
| PostgreSQL | Medium | $0 (local) | Medium |
| MongoDB | Medium | $0 (local) | Medium |
| SQLite | None | $0 | None |
| Backend | Monthly Cost | Setup Time | Maintenance |
|---|---|---|---|
| PostgreSQL (RDS t3.small) | ~$30 | 1 hour | Low |
| MongoDB (Atlas M10) | ~$60 | 30 min | Very Low |
| SQLite (EC2 t3.micro) | ~$10 | 30 min | Medium |
| Backend | Monthly Cost | Setup Time | Maintenance |
|---|---|---|---|
| PostgreSQL (RDS t3.medium) | ~$120 | 2 hours | Low |
| MongoDB (Atlas M30) | ~$250 | 1 hour | Very Low |
| SQLite | Not recommended | - | - |
| Backend | Monthly Cost | Setup Time | Maintenance |
|---|---|---|---|
| PostgreSQL (RDS r5.xlarge) | ~$500+ | 4 hours | Medium |
| MongoDB (Atlas M60+) | ~$800+ | 2 hours | Low |
| SQLite | Not recommended | - | - |
| Feature | PostgreSQL | MongoDB | SQLite |
|---|---|---|---|
| Foreign Keys | ✅ Enforced | ❌ Application-level | ✅ Enforced |
| Unique Constraints | ✅ Yes | ✅ Yes | ✅ Yes |
| Check Constraints | ✅ Yes | ✅ Yes | |
| NOT NULL | ✅ Yes | ✅ Yes | |
| Triggers | ✅ Yes | ✅ Yes | ✅ Yes |
| Feature | PostgreSQL | MongoDB | SQLite |
|---|---|---|---|
| SQL Support | ✅ Full SQL | ❌ MQL only | ✅ Full SQL |
| Joins | ✅ All types | ✅ All types | |
| Subqueries | ✅ Yes | ✅ Yes | |
| Window Functions | ✅ Yes | ✅ Yes | |
| CTEs | ✅ Yes | ❌ No | ✅ Yes |
| Aggregations | ✅ Yes | ✅ Pipeline | ✅ Yes |
| Feature | PostgreSQL | MongoDB | SQLite |
|---|---|---|---|
| Full-Text Search | ✅ tsvector | ✅ Text indexes | ✅ FTS5 |
| Geospatial | ✅ PostGIS | ✅ Built-in | |
| Multi-Tenancy | ✅ SQL Isolation | ✅ Collection Level | ✅ SQL Isolation |
| RBAC / TBAC | ✅ Built-in (Migs) | ✅ Supported | ✅ Built-in (Schema) |
| Audit Logging | ✅ Automated | ✅ Supported | ✅ Automated |
| Federated Catalogs | ✅ Supported | ✅ Supported | ✅ Supported |
| JSON Queries | ✅ JSONB operators | ✅ Native | ✅ JSON1 |
| Feature | PostgreSQL | MongoDB | SQLite |
|---|---|---|---|
| Auto-Initialization | ✅ Yes (sqlx migs) | ✅ Yes (embedded) | |
| Auto-Migrations | ✅ Yes (sqlx) | ❌ Manual | ❌ Manual (reset req) |
| Manual Indexing | ❌ Not required | ✅ Essential | ❌ Not required |
- ✅ You need proven, enterprise-grade reliability
- ✅ You want strong data integrity (foreign keys)
- ✅ You're familiar with SQL
- ✅ You need complex queries and joins
- ✅ You want managed cloud options (RDS)
- ✅ You're building a traditional web application
- ✅ You need excellent tooling and ecosystem
- ✅ You need horizontal scalability
- ✅ You prefer document-based data model
- ✅ You want flexible schema evolution
- ✅ You're building cloud-native applications
- ✅ You need multi-region deployments
- ✅ You're already using MongoDB
- ✅ You want excellent managed service (Atlas)
- ✅ You're developing locally
- ✅ You need embedded database
- ✅ You're deploying to edge/IoT devices
- ✅ You want zero configuration
- ✅ You have low concurrent write needs
- ✅ You want minimal resource usage
- ✅ You're prototyping or testing
Difficulty: Medium Tools: Custom scripts, pgloader Downtime: Required Use Case: Moving from development to production
Difficulty: Hard Tools: Custom scripts Downtime: Required Use Case: Rare
Difficulty: Hard Tools: Custom ETL Downtime: Required Use Case: Architectural change
All backends have comprehensive test coverage:
| Backend | Tests | Status |
|---|---|---|
| PostgreSQL | Shared Regression Suite + Integration | ✅ All passing |
| MongoDB | Shared Regression Suite + Integration | ✅ All passing |
| SQLite | Shared Regression Suite + Integration | ✅ All passing |
Recommended: SQLite → PostgreSQL
- Start with SQLite for rapid development
- Migrate to PostgreSQL when you have users
Recommended: PostgreSQL
- Proven reliability
- Excellent tooling
- Strong consistency
Recommended: MongoDB
- Horizontal scalability
- Managed service (Atlas)
- Multi-region support
Recommended: SQLite
- Embedded
- Low resources
- No network required
Recommended: PostgreSQL or MongoDB
- Both provide excellent tenant isolation
- PostgreSQL: Better for complex queries
- MongoDB: Better for horizontal scaling
All three backends are production-ready and fully tested. Your choice should be based on:
- Deployment Environment: Cloud, on-prem, edge?
- Scale Requirements: How many users/requests?
- Team Expertise: SQL vs NoSQL familiarity?
- Budget: Managed vs self-hosted costs?
- Data Model: Relational vs document fit?
Default Recommendation: Start with SQLite for development, use PostgreSQL for production unless you specifically need MongoDB's horizontal scaling.