PostgreSQL vs DynamoDB
A general-purpose relational DB vs a managed key-value/document store. Postgres gives full SQL and query flexibility you operate yourself; DynamoDB gives horizontal scale and zero ops for key-based access patterns, at the cost of query flexibility.
| Dimension | PostgreSQL | DynamoDB |
|---|---|---|
| Query model | Full SQL, joins, ad-hoc queries, transactions. | Key + sort-key access only; no joins; limited secondary indexes. |
| Scaling | Single primary; you shard to scale writes. | Scales horizontally automatically by partition key. |
| Ops | You run, tune, back up, and scale it. | Fully managed; no capacity planning (on-demand). |
| Consistency | Strong ACID; serializable available. | Tunable; strong only on a single item, eventual for GSIs. |
| Cost shape | Instance + storage + IOPS; predictable. | Per-request/throughput + storage; hot keys and GSIs can blow up cost. |
Query model
- PostgreSQL
- Full SQL, joins, ad-hoc queries, transactions.
- DynamoDB
- Key + sort-key access only; no joins; limited secondary indexes.
Scaling
- PostgreSQL
- Single primary; you shard to scale writes.
- DynamoDB
- Scales horizontally automatically by partition key.
Ops
- PostgreSQL
- You run, tune, back up, and scale it.
- DynamoDB
- Fully managed; no capacity planning (on-demand).
Consistency
- PostgreSQL
- Strong ACID; serializable available.
- DynamoDB
- Tunable; strong only on a single item, eventual for GSIs.
Cost shape
- PostgreSQL
- Instance + storage + IOPS; predictable.
- DynamoDB
- Per-request/throughput + storage; hot keys and GSIs can blow up cost.
When PostgreSQL wins
- You need joins, ad-hoc queries, transactions, or rich types.
- You can operate a database and want full control.
When DynamoDB wins
- Access patterns are key-based and known; you want zero DB ops.
- Write throughput exceeds what a single Postgres primary can handle.
Verdict
Use Postgres when query flexibility and correctness matter; DynamoDB when access patterns are simple, key-based, and you want managed horizontal scale. Many systems use both — Postgres for relational data, DynamoDB for high-scale key lookups.