Book a free call

Which Database Should Your Web App Use? A Practical Comparison

A practical list of the databases teams actually pick for web apps, what each is good at, and how to choose one without over-engineering your first schema.

Hertiv engineering teamReviewed by a senior engineer
7 min read
Which Database Should Your Web App Use? A Practical Comparison
On this page

Short answer

Most web apps choose between PostgreSQL, MySQL, MongoDB, Redis and a few managed alternatives. Pick based on your data shape, read/write pattern and team skills rather than benchmarks. Relational databases remain the safe default for transactional apps.

Which databases do web apps actually use?

Most production web apps run one primary transactional database, often with a cache and a search or analytics store alongside it. The list below covers the databases you will meet most often in new projects and existing codebases.

Database Data model Typical role Operational effort
PostgreSQL Relational, JSON, extensions Primary app database Moderate
MySQL / MariaDB Relational Primary app database Moderate
MongoDB Document Primary for flexible schemas Moderate
Redis Key-value, in-memory Cache, sessions, queues Low
SQLite Relational, embedded Edge, mobile, small tools Very low
Microsoft SQL Server Relational Primary in Microsoft-heavy stacks Moderate
DynamoDB Key-value, document High-scale serverless apps Low with managed setup
Elasticsearch / OpenSearch Search index Full-text search, logs Higher
ClickHouse Columnar Analytics on large event data Higher

The right pick depends on the access pattern, the team that will operate it, and how much schema change you expect in the first year. For most transactional apps, a relational database is the safer default and stays useful as the product grows.

Relational databases: PostgreSQL, MySQL and SQL Server

Relational databases store data in tables with defined relationships, and they remain the default for transactional web apps. They give you transactions, constraints and a query language your team probably already knows.

PostgreSQL

PostgreSQL is the most common default for new projects. It handles JSON columns, full-text search, geospatial data through extensions and vector search through pgvector, which means you can prototype AI features without adding a separate store. It has strong standards compliance and a mature ecosystem. The trade-off is that tuning, indexing and migrations need attention as data grows.

MySQL and MariaDB

MySQL is widely hosted, well documented and familiar to many teams. MariaDB is a compatible fork used in several hosting stacks. Both are reasonable choices when your team already knows them or your provider makes them the easy option. Features around JSON and window functions are weaker than PostgreSQL, though they have improved.

Microsoft SQL Server

SQL Server fits organisations already standardised on Microsoft tooling, Active Directory and Azure. Licensing cost and platform lock-in are the main concerns. For a new, cloud-neutral product, it is rarely the first pick unless the surrounding stack requires it.

Whatever you choose, treat the schema as a product decision. A clear relational model early on saves weeks of migration work later. For help reviewing data models before launch, see data engineering services.

Document and key-value databases: MongoDB, Redis, DynamoDB

Non-relational databases trade rigid schemas for flexibility, and they work best when the data genuinely looks like documents or key lookups.

MongoDB

MongoDB stores JSON-like documents and lets you change the shape of records without a migration. That suits content systems, product catalogues with variable attributes and event payloads. The risk is that flexible schemas drift until queries and indexes become hard to manage. Use schema validation at the application layer and agree on field names early.

Redis

Redis is an in-memory store used for caching, session data, rate limiting and lightweight queues. It is fast and simple to operate. It is rarely the system of record, because persistence and memory cost make that an awkward fit at scale. Treat it as an accelerator in front of a primary database.

DynamoDB

DynamoDB is a managed key-value and document store from AWS. It scales without much operational work, but access patterns must be designed up front, and queries are limited to what your keys and indexes support. It suits serverless workloads with predictable access patterns and a team comfortable with AWS.

In practice, many apps combine one of these with a relational primary database rather than replacing it. The decision is about which workload each store serves, not which one wins overall.

Specialised stores: SQLite, search and analytics

Some databases exist for a narrow job and do it better than a general-purpose system. Adding one should be a deliberate decision, because each store adds operational work.

SQLite

SQLite is an embedded relational database that runs inside your application process. It suits mobile apps, desktop tools, edge functions and small internal services. It is not designed for many concurrent writers over a network, so avoid it as the primary store for a busy multi-user web app.

Elasticsearch and OpenSearch

These are search engines built on an inverted index. They handle full-text search, faceted filtering and log analysis well. Keeping them in sync with your primary database adds complexity, so only add one when search quality is a real product requirement. PostgreSQL full-text search is often enough for smaller catalogues.

ClickHouse and columnar stores

ClickHouse and similar columnar databases are built for aggregating large volumes of event data quickly. They suit product analytics, dashboards and reporting on high-volume logs. They are a poor fit for transactional writes, so pair them with a primary database rather than using them alone.

A useful rule is to start with one database and add a specialist store only when a specific query or workload has become a measured problem.

Managed versus self-hosted databases

A managed database is run by a cloud provider, which handles backups, patching, failover and some tuning. Self-hosting means your team runs the database on its own infrastructure.

Managed services reduce operational load and are usually the right default for small and mid-sized teams. The trade-offs are cost at scale, vendor-specific behaviour and less control over configuration. Backups exist, but you still need to test restores and set retention policies that match your compliance obligations.

Self-hosting gives you full control over versions, extensions and tuning. It also means you own upgrades, replication, monitoring and incident response. That is reasonable when you have platform engineers who already do this work, or when data residency rules require it.

A middle path is running a database on your own cloud account with a managed operator. You keep data in your environment while still getting automated failover and backups. Whichever route you choose, decide early where data lives and who is on call when it fails.

How to choose a database for your web app

Start from the workload and the team, not from a feature list. The steps below keep the decision grounded and reversible.

  1. Describe your access patterns. Write down the five most important queries and how often they run. If they are mostly lookups by ID and joins across related records, a relational database fits. If records vary heavily in shape, a document store may fit better.
  2. Check your consistency needs. Payments, inventory and bookings need transactions and constraints. Relational databases handle these well. If you can tolerate eventual consistency, more options open up.
  3. Estimate data size and growth in words, not precise numbers. A store that fits today may need partitioning in a year. Confirm the database has a clear path for that.
  4. Match your team's skills. A database your engineers can operate, back up and debug is worth more than one with better benchmarks they cannot run.
  5. Prefer one primary database. Add a cache, search index or analytics store only when a measured need appears.
  6. Revisit the choice at clear milestones. Changing a primary database is expensive, but so is staying on the wrong one for years.

For teams building a new product, the surrounding architecture matters as much as the database. Our web application development team can help scope the data layer alongside the rest of the stack.

Common mistakes when picking a web app database

Most database problems in web apps come from process, not from the engine itself. These are the ones that show up repeatedly.

  • Choosing for imagined scale. A database that handles ten times your current load is not useful if the team cannot operate it today.
  • Skipping schema design. Even document databases need agreed field names, indexes and validation.
  • Treating the cache as the source of truth. Redis data can be lost or evicted; sessions and critical state belong in a durable store.
  • Ignoring migrations. Plan how schema changes will be applied safely before the first release, not after.
  • Forgetting backup restores. A backup that has never been restored is an assumption, not a recovery plan.
  • Adding stores too early. Each additional database adds monitoring, credentials, failure modes and cost.
  • Using the wrong store for analytics. Running heavy reports on your primary database slows down the product.

Key takeaways

  • PostgreSQL is the default for most new web apps: relational, extensible, with JSON, full-text and vector support.
  • MySQL and MariaDB remain solid choices where hosting, tooling or team familiarity already points that way.
  • MongoDB fits apps with flexible, document-shaped data, but schema discipline still matters.
  • Redis is usually a cache or queue alongside a primary database, not the system of record.
  • Managed cloud databases reduce operational load but add lock-in and vendor-specific limits.
  • Choose for the next two years of load and your team's ability to operate it, not for a hypothetical scale.

Frequently asked questions

Is PostgreSQL better than MySQL for web apps?

For most new web apps, PostgreSQL is the more flexible default because of its JSON, full-text and extension support. MySQL is a fine choice when your team knows it well or your hosting platform favours it. The difference matters less than schema design and query quality.

Can I use MongoDB for a transactional web app?

Yes, MongoDB supports multi-document transactions, and many apps use it successfully. You need disciplined schema design and clear indexing. If your data is highly relational with many joins, a relational database is usually simpler to reason about.

Do I need a separate cache if I use a fast database?

Not at first. Add a cache like Redis when you can measure repeated reads that strain the primary database. Caching adds invalidation logic and a second system to monitor, so introduce it for a specific bottleneck rather than by default.

How many databases should a web app use?

Start with one primary transactional database. Add a cache, search index or analytics store only when a specific workload justifies it. Each additional store adds operational cost, so keep the set small and documented.

Is a managed database worth the cost?

For most teams, yes. Managed services handle patching, backups and failover, which are easy to neglect. Self-hosting makes sense when you have platform engineers, strict data residency needs or heavy custom tuning requirements.

Can I change my database later?

You can, but it is a significant project involving schema translation, data migration and dual-run testing. Choose a database that fits your next two years of load and data shape, and keep the data access layer clean so a future move stays possible.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: software products in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Picking a database for a new web app or reworking an awkward schema? Talk to Hertiv about the data layer.

A senior engineer replies within one business day. Or see our Web App Development service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to [email protected].

Prefer email? Write to [email protected]
Estimate costBook a call