Topics & Navigation

Web Development

PostgreSQL vs SQLite vs MySQL: Which Database for Your Web App?

Table of contents (17 sections)

In short: choose SQLite for small single-server apps, internal tools and anything that must be simple to run and back up. Choose PostgreSQL when you need many concurrent writers, richer data types or room to grow. Choose MySQL or MariaDB when your stack already depends on them, as WordPress does. For a new project with no constraint, PostgreSQL is the safest default.

A database is one of the few decisions that is expensive to reverse. Pick a heavy server for a weekend project and you will maintain infrastructure you do not need. Pick a lightweight option for a product that grows and you will migrate under pressure. This guide compares PostgreSQL, SQLite and MySQL on the points that matter for web applications, then gives you a decision guide and a way to measure the answer on your own workload.

Prerequisites

  • Basic SQL knowledge (SELECT, JOIN, INSERT, indexes)
  • A rough idea of your application: expected users, write frequency and how many servers will run it
  • Optional: Docker if you want to try PostgreSQL locally

The quick comparison

| Criterion | SQLite | PostgreSQL | MySQL / MariaDB |
|—|—|—|—|
| Architecture | Library embedded in your app, data in one file | Separate database server | Separate database server |
| Concurrent writes | One writer at a time | Many concurrent writers | Many concurrent writers |
| Setup effort | None | Moderate | Moderate |
| Data types and features | Compact, flexible typing, JSON functions, full-text search | Very rich: JSONB, arrays, extensions, row-level security | Solid and widely supported, fewer advanced types |
| Hosting | Runs wherever your app runs | Managed and self-hosted options everywhere | Available on almost every shared host |
| Backups | Copy or snapshot a file | Dumps, base backups, point-in-time recovery | Dumps, binary logs, replication |
| Best for | Small apps, tools, edge and embedded use | Most new web products | Existing MySQL ecosystems, WordPress |

How they differ in practice

SQLite: a database as a file

SQLite is not a server. It is a library that your application links to, and the whole database lives in a single file. That means no network, no credentials to manage and no daemon to monitor. Backups can be as simple as copying a file, and tests can create a fresh database in milliseconds. This is also why tools like PocketBase embed it: you ship one program and you have a backend.

The trade-off is write concurrency. In its default mode, a writer blocks readers. Turning on write-ahead logging (WAL) lets readers continue while one write transaction runs, but there is still only one writer at a time. For a blog, a dashboard or an internal tool this is rarely a problem. For an application with constant parallel writes from many users, it becomes the bottleneck. The SQLite project itself explains when to use SQLite and when a client-server database fits better.

Apply these settings when you open the database:

sqlPRAGMA journal_mode = WAL;
PRAGMA busy_timeout = 5000;
PRAGMA foreign_keys = ON;

WAL improves concurrency, busy_timeout makes a writer wait instead of failing immediately, and foreign keys are off by default in SQLite, so you must enable them yourself.

PostgreSQL: the capable default

PostgreSQL uses multi-version concurrency control, so readers and writers do not block each other, and many writers can work in parallel. It has strict typing, strong transactional guarantees and a large set of features that save you application code: JSONB columns with indexes, arrays, window functions, row-level security and extensions such as PostGIS for geographic data and pgvector for embeddings. You can start with a simple schema and add these as you need them.

The cost is operations. You run a server, tune a few settings, manage users, plan upgrades and take proper backups. On a small VPS this is easy with Docker or a managed service, but it is still more than a file.

MySQL and MariaDB: the ecosystem choice

MySQL and its fork MariaDB are available almost everywhere and power a huge share of the web, including every WordPress site. If you run WordPress, you already depend on one of them. For new custom applications, MySQL is a perfectly good engine, but PostgreSQL usually offers more built-in features, while SQLite offers more simplicity. Choose MySQL when your hosting, team skills or existing tools point there, not because of a benchmark you read once.

A simple decision guide

Ask these questions in order:

  1. Will more than one server write to the data? If yes, use PostgreSQL or MySQL. SQLite should not be shared across machines over a network file system.
  2. Do you expect sustained parallel writes? If yes, choose PostgreSQL or MySQL.
  3. Do you need advanced features such as JSONB indexing, geospatial queries, vector search or row-level security? Choose PostgreSQL.
  4. Is your project small, single-server and read-heavy? SQLite is likely enough and removes a whole layer of operations.
  5. Are you extending an existing PHP or WordPress stack? Stay with MySQL or MariaDB.
  6. Still unsure? Start with PostgreSQL. It is the option you are least likely to outgrow.

Measure it on your workload

Generic benchmarks rarely match your queries. Test with realistic data and your own access pattern. For PostgreSQL, the bundled pgbench tool gives a quick baseline:

bashpgbench -i -s 10 appdb          # create test tables (scale factor 10)
pgbench -c 10 -j 2 -T 30 appdb  # 10 clients, 2 threads, 30 seconds

Then replay your real queries and compare latency at the 95th percentile, not only the average. Use EXPLAIN ANALYZE to see whether an index is used:

sqlEXPLAIN ANALYZE
SELECT * FROM orders WHERE customer_id = 42 ORDER BY created_at DESC LIMIT 20;

A missing index will matter more than the choice of engine in most small applications.

Operations: backups, hosting and cost

  • SQLite: use the .backup command or a file-system snapshot, never a plain copy of a file that is being written. See our guide to PocketBase backup and restore for a working script.
  • PostgreSQL: use pg_dump for logical backups and a base backup with WAL archiving for point-in-time recovery. Many hosts offer this as a managed feature.
  • MySQL or MariaDB: use mysqldump or physical backups plus binary logs.

Whatever you choose, test a restore. A backup you have never restored is only a hope.

Migrating later

Moving from SQLite to PostgreSQL is common as a project grows, and it is manageable if you prepare. Use an ORM or query builder so most SQL is portable, avoid SQLite-only behaviour, and keep migrations in version control. Typical differences to watch:

  • Typing: SQLite is flexible about types, PostgreSQL is strict. Bad data hidden by SQLite shows up during migration.
  • Auto-increment: SQLite’s AUTOINCREMENT becomes an identity column in PostgreSQL.
  • Case sensitivity and collation: LIKE behaves differently between engines.
  • Dates and booleans: stored as text or integers in SQLite, native types in PostgreSQL.

The open-source tool pgloader can load an SQLite database into PostgreSQL, which saves a lot of manual work.

Common mistakes

  • Putting SQLite on a network file system shared by several app servers
  • Forgetting busy_timeout and then seeing “database is locked” errors
  • Running PostgreSQL with default settings and no connection pooling when many app instances connect
  • Choosing a database for a benchmark instead of for the team’s ability to run and restore it
  • Skipping indexes and blaming the engine for slow queries

FAQ

Is SQLite fast enough for production?

Yes, for the right workload. Many read-heavy sites and tools run on it comfortably. The limit is concurrent writes, not raw speed.

Can PostgreSQL run on a small VPS?

Yes. With sensible memory settings it runs well on a modest server. Use Docker or your distribution’s package, and set up backups on day one.

Should I use MySQL or MariaDB?

Use whichever your hosting and tools support best. They are close cousins, but they have diverged over time, so test your queries on the one you deploy.

Can I start with SQLite and migrate later?

Yes, and it is a good approach for prototypes. Keep your schema and queries clean, use migrations, and plan the move before you hit write contention.

Next steps

If you want a backend that embeds SQLite, read PocketBase: the easy way to create your secure REST API and our production deployment guide. For PostgreSQL in containers, continue with Docker Compose in production, and check the official PostgreSQL documentation for installation and tuning.