DynamoDB vs PostgreSQL: when a key-value database beats SQL (and when it doesn't)

DynamoDB vs PostgreSQL compared on data modelling, scale, cost, queries and lock-in, with the workloads that suit each and when to use both.

INDI TECHNOLOGY4 min read

On AWS, many teams face a choice between DynamoDB, a fully managed key-value and document database, and PostgreSQL on RDS or Aurora. DynamoDB promises effortless scale with no servers to manage. PostgreSQL promises flexible queries and strong relational integrity. Both promises are true, and the right choice depends on how well you know your access patterns.

At a glance

DynamoDB PostgreSQL (RDS / Aurora)
Model Key-value and document; items in tables with partition and sort keys Relational tables, SQL, JSONB
Queries By key and sort-key ranges; secondary indexes; no joins Any query; joins, aggregates, ad-hoc
Schema design Designed around access patterns (often single-table design) Designed around entities and relationships
Scale Virtually unlimited, automatic Vertical scaling plus read replicas; Aurora scales storage automatically
Latency Single-digit milliseconds at any scale Low; depends on queries and load
Operations Serverless: no instances, no patching Managed, but you size instances and plan upgrades
Pricing Per request (on-demand) or provisioned capacity, plus storage Per instance-hour (or Aurora Serverless capacity), plus storage and I/O
Transactions Supported (up to 100 items per transaction) Full ACID, any size
Analytics and reporting Poor directly; export to S3 or a warehouse Good (with read replicas)
Portability AWS-only Runs anywhere

DynamoDB: excellent for known, simple access patterns

DynamoDB shines when you know exactly how data will be read and written:

  • get a session, cart or profile by ID
  • list a user's orders by date
  • store device or event data keyed by device and time
  • count, rate-limit or deduplicate at very high volume

It scales smoothly from zero to huge traffic with no tuning, and on-demand pricing means tiny cost at low volume. Streams make it easy to trigger functions on changes.

The catch: you design tables around queries in advance. A new kind of query later ("show all orders over ₹10,000 in Pune last month") may need a new index or a data export. Teams new to DynamoDB often recreate relational patterns badly, which leads to complexity and cost.

PostgreSQL: excellent when queries evolve

PostgreSQL handles changing requirements well. You model entities and relationships, add indexes as queries appear, and run reports directly. Constraints and transactions keep data correct. For most business applications (SaaS products, marketplaces, fintech cores, internal systems), requirements evolve constantly, which favours SQL.

Its scaling limits are real but far away for most products: a single large instance with read replicas handles a lot, and Aurora adds fast replicas and automatic storage growth.

Cost

  • DynamoDB on-demand is very cheap at low volume and scales linearly with requests. At high, steady volume, provisioned capacity with autoscaling is cheaper. Watch out for large items, scans and too many secondary indexes, all of which multiply cost.
  • PostgreSQL costs are mostly instance size, so cost is flat until you need a bigger instance. Low-traffic apps pay for an always-on instance (Aurora Serverless reduces this).

A common pattern: use both

Many AWS systems use PostgreSQL as the system of record and DynamoDB for specific high-volume, simple workloads around it:

  • PostgreSQL: customers, accounts, orders, payments, inventory, reports
  • DynamoDB: sessions, rate limits, idempotency keys, carts, feature flags, event and IoT data, caches of read models

Choose DynamoDB if…

  • access patterns are known, simple and key-based
  • you need massive or highly variable scale with no capacity planning
  • you're building serverless on AWS and want no database servers
  • the data is sessions, carts, events, device data or similar

Choose PostgreSQL if…

  • the product's data is relational and requirements will change
  • you need reporting, ad-hoc queries or complex transactions
  • you want portability across clouds
  • data integrity rules matter (fintech, health, compliance)

Recommendation by use case

Workload Pick
SaaS product core data PostgreSQL
E-commerce orders and inventory PostgreSQL
Shopping carts and sessions DynamoDB (or Redis/Valkey)
IoT and meter readings at high volume DynamoDB, or a time-series database
Idempotency keys and rate limiting DynamoDB
Travel search results cache DynamoDB
Ledger and payments PostgreSQL

Summary

Use DynamoDB for high-volume, key-based workloads whose access patterns you know well. Use PostgreSQL as the system of record for business data, where queries evolve and integrity matters. Using both, each where it's strongest, is common and sensible on AWS.

We design data architectures on AWS and other clouds through our cloud and infrastructure work. Talk to us about your workload.

Any idea in mind? Let's make it real.

Tell us what you're building. You'll hear back from an engineer, not a sales team, usually within one working day.

Book a 30-min call