PostgreSQL vs MySQL vs SQLite: Choosing the Right Database
Compare PostgreSQL, MySQL, and SQLite on features, performance, scalability, and use cases. Find the best relational database for your project in 2026.
What you'll learn
- ✓Key architectural differences between PostgreSQL, MySQL, and SQLite
- ✓Performance characteristics and scalability limits
- ✓Feature sets that matter for real projects
- ✓How to choose the right database for your use case
Prerequisites
- •Basic understanding of SQL and relational databases
PostgreSQL, MySQL, and SQLite are the three most widely used relational databases in the world, but they serve very different purposes. PostgreSQL is a full-featured enterprise database. MySQL is the workhorse behind most web applications. SQLite is an embedded database that runs inside your application process. This comparison helps you choose the right tool for your project.
Quick Comparison
| Feature | PostgreSQL | MySQL | SQLite |
|---|---|---|---|
| Type | Client-server | Client-server | Embedded (serverless) |
| License | PostgreSQL License (permissive) | GPL v2 / Commercial | Public domain |
| ACID compliance | Full | Full (with InnoDB) | Full |
| Max database size | Unlimited (practical) | Unlimited (practical) | 281 TB |
| JSON support | Excellent (JSONB) | Good (JSON type) | Basic (JSON1 extension) |
| Full-text search | Built-in (tsvector) | Built-in (InnoDB) | FTS5 extension |
| Replication | Streaming, logical | Primary-replica, group | None built-in |
| Concurrency model | MVCC, row-level locks | MVCC (InnoDB), row-level locks | File-level locking (WAL mode helps) |
| Best for | Complex queries, data integrity | Web applications, read-heavy | Mobile apps, embedded, prototyping |
PostgreSQL
PostgreSQL is often called “the world’s most advanced open-source database.” It prioritizes correctness, standards compliance, and extensibility. If you need advanced data types, complex queries, or strict data integrity, PostgreSQL is the default choice.
Key Features
PostgreSQL excels at features no other open-source database matches:
- Advanced data types: Arrays, hstore (key-value), JSONB (binary JSON with indexing), ranges, geometric types, network address types, and custom types
- Window functions and CTEs: Full support for analytical queries
- Partial indexes: Index only rows that match a condition
- UPSERT:
INSERT ... ON CONFLICTfor clean upsert operations - Extensions: PostGIS for geospatial, TimescaleDB for time-series, pg_trgm for fuzzy search
-- PostgreSQL: JSONB query with indexing
CREATE TABLE products (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
metadata JSONB DEFAULT '{}'
);
CREATE INDEX idx_metadata ON products USING GIN (metadata);
-- Query nested JSON efficiently
SELECT name
FROM products
WHERE metadata @> '{"category": "electronics"}'
AND (metadata->>'price')::numeric < 500;
When PostgreSQL Shines
PostgreSQL is the right choice when you need complex queries, strong data integrity, geospatial data, or JSON storage alongside relational data. It handles mixed workloads (read and write heavy) well and scales vertically to handle large datasets.
Limitations
PostgreSQL uses more memory and CPU than MySQL for simple queries. Configuration requires more expertise. Replication setup is more involved than MySQL’s, and the ecosystem of managed hosting options, while growing, has historically been smaller.
MySQL
MySQL powers most of the web. It is the “M” in LAMP stack and the database behind WordPress, Shopify, and Facebook (which runs a heavily modified fork). MySQL prioritizes simplicity, speed for common operations, and ease of administration.
Key Features
- Speed for simple queries: MySQL’s query optimizer is tuned for common web application patterns
- Replication: Primary-replica replication is straightforward to set up
- InnoDB engine: ACID compliance, row-level locking, crash recovery
- Wide hosting support: Every hosting provider supports MySQL
- Mature tooling: MySQL Workbench, phpMyAdmin, and hundreds of GUI clients
-- MySQL: Common web application pattern
CREATE TABLE users (
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
email VARCHAR(255) NOT NULL UNIQUE,
username VARCHAR(100) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
INDEX idx_username (username)
) ENGINE=InnoDB;
-- Simple, fast read
SELECT id, username, email
FROM users
WHERE username = 'johndoe'
LIMIT 1;
When MySQL Shines
MySQL is ideal for read-heavy web applications, content management systems, and scenarios where simplicity and widespread hosting support matter. It is the path of least resistance for most web projects.
Limitations
MySQL’s SQL compliance is less strict than PostgreSQL’s. Some features that PostgreSQL handles natively (arrays, advanced JSON indexing, window functions in older versions) require workarounds. The dual licensing model (GPL for community, commercial for enterprise) can be a concern. MySQL’s handling of edge cases (silent data truncation, implicit type conversions) can surprise developers used to stricter databases.
SQLite
SQLite is not a traditional database server. It is a C library that reads and writes directly to a file on disk. There is no separate server process, no configuration, and no network protocol. The entire database is a single file you can copy, back up, or email.
Key Features
- Zero configuration: No server to install, configure, or manage
- Serverless: Runs in-process, no network latency
- Single-file database: The entire database is one portable file
- Incredibly reliable: Billions of deployments, exhaustive test suite
- Small footprint: Under 1 MB for the complete library
-- SQLite: Perfect for local data
-- No server needed, just open a file
-- sqlite3 myapp.db
CREATE TABLE notes (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL,
content TEXT,
created_at TEXT DEFAULT (datetime('now'))
);
INSERT INTO notes (title, content)
VALUES ('First note', 'SQLite is wonderfully simple.');
SELECT * FROM notes WHERE title LIKE '%first%';
When SQLite Shines
SQLite is perfect for mobile applications (it is the default database on iOS and Android), desktop applications, embedded systems, prototyping, testing, and any scenario where you want a database without operational overhead. It also works surprisingly well for read-heavy web applications with low to moderate traffic.
Limitations
SQLite uses file-level locking, which limits write concurrency. WAL mode improves this significantly, but it cannot match PostgreSQL or MySQL for concurrent write-heavy workloads. There is no built-in replication, no user management, and no network access. It is not designed for multi-server deployments.
Performance Comparison
Read Performance
For simple primary key lookups and indexed queries, all three are fast. SQLite often wins for single-user scenarios because there is no network overhead. MySQL is optimized for read-heavy web patterns. PostgreSQL’s query planner excels at complex analytical queries with joins and aggregations.
Write Performance
PostgreSQL and MySQL handle concurrent writes well with row-level locking. SQLite’s write performance is limited by its file-level locking; only one writer can operate at a time. For write-heavy workloads with many concurrent users, PostgreSQL and MySQL are the clear choices.
Complex Queries
PostgreSQL dominates for complex analytical queries, window functions, recursive CTEs, and JSON operations. Its query planner is the most sophisticated of the three. MySQL has improved significantly in recent versions but still lags for complex analytical workloads. SQLite handles moderately complex queries well but lacks some advanced features.
Scalability
Vertical Scaling
All three scale vertically (bigger machine, more RAM). PostgreSQL and MySQL can effectively use hundreds of gigabytes of RAM and dozens of CPU cores. SQLite’s scaling is limited by the single-writer constraint.
Horizontal Scaling
PostgreSQL supports streaming replication and logical replication. Read replicas are straightforward. Tools like Citus extend PostgreSQL with horizontal sharding.
MySQL’s replication is its strongest scaling feature. Primary-replica setups are simple, and group replication enables multi-primary configurations. ProxySQL and MySQL Router handle read/write splitting.
SQLite has no built-in replication. Tools like Litestream enable streaming replication of SQLite databases, and LiteFS provides distributed SQLite, but these are external solutions.
Data Integrity
PostgreSQL is the strictest. It enforces constraints, rejects invalid data, and follows the SQL standard closely. You get what you expect.
MySQL with strict mode enabled is reasonably strict, but historically it allowed silent data truncation and questionable implicit conversions. Modern MySQL with STRICT_TRANS_TABLES and ONLY_FULL_GROUP_BY is much better.
SQLite uses dynamic typing by default. A column declared as INTEGER can store text. The STRICT table option (added in version 3.37) enforces type checking.
When to Choose PostgreSQL
- You need advanced data types (JSONB, arrays, geospatial)
- Data integrity and correctness are paramount
- Your queries are complex with many joins, CTEs, or window functions
- You need a database that can grow with your application for years
- You want an extensible platform (PostGIS, TimescaleDB, pgvector)
When to Choose MySQL
- You are building a typical web application with standard CRUD operations
- Read-heavy workload with simple queries
- You need easy replication and wide hosting support
- Your team is already experienced with MySQL
- You are using a CMS like WordPress or Drupal
When to Choose SQLite
- Mobile or desktop application with local data storage
- Prototyping and development before migrating to PostgreSQL or MySQL
- Testing (use SQLite in tests, production database in deployment)
- Low-traffic websites or internal tools
- Embedded systems or IoT devices
- You want zero operational overhead
Final Verdict
PostgreSQL is the best general-purpose choice for new server-side projects in 2026. Its feature set is unmatched, and the ecosystem of managed hosting (Neon, Supabase, AWS RDS) has removed the operational complexity argument.
MySQL remains the right choice when you need maximum simplicity for web applications, wide hosting compatibility, or when your team and tooling already revolve around it.
SQLite is not a “lesser” database. It is the most deployed database engine in the world and is the right choice whenever you need a database without a server. For many applications, particularly those with a single server or low write concurrency, SQLite is not just acceptable but optimal.
Pick the tool that fits your constraints: team expertise, deployment environment, query complexity, and concurrency requirements.
Related articles
- SQL MongoDB vs PostgreSQL: When to Use Each Database
Compare MongoDB and PostgreSQL across data modeling, performance, scalability, and use cases. Choose the right database for your project.
- SQL Postgres vs MySQL: A Practical Comparison
A grounded comparison of Postgres and MySQL across data types, transactions, replication, JSON, and ecosystem - so you can pick the right one for your project.
- AWS AWS RDS vs Aurora: Managed Database Comparison
Compare AWS RDS and Aurora for MySQL and PostgreSQL workloads. Learn architecture differences, performance, pricing, and when to choose each service.
- Go Go Database Patterns with sqlx and pgx
Master Go database patterns using sqlx and pgx for PostgreSQL including connection pooling, transactions, batch operations, and repository design.