9bNine Bits

DynamoDB vs PostgreSQL: Which Database Should You Use?

Choose DynamoDB when your access patterns are known up front and you need predictable low-latency reads and writes at any scale; choose PostgreSQL when you need joins, ad hoc queries, or multi-table transactions. DynamoDB is a fully managed key-value and document service. PostgreSQL is a relational database you can self-host or run managed through Amazon Aurora or Amazon RDS.
DynamoDB vs PostgreSQL: Which Database Should You Use?

Decision Summary: DynamoDB or PostgreSQL

DynamoDB fits workloads with a small, known set of access patterns, such as session stores, shopping carts, device state, or event ingestion. PostgreSQL fits workloads where the data has real relationships, where reporting and ad hoc queries matter, or where the questions you will ask are not fully known in advance. Many systems use both: DynamoDB for high-throughput operational paths and PostgreSQL (often on Aurora or RDS) for the relational core.

CriterionDynamoDBPostgreSQL
Data modelKey-value and document; single-table design driven by access patternsRelational; normalized tables with foreign keys
ReadsEventually consistent by default; strongly consistent reads optional (not on global secondary indexes)Reads see committed data under MVCC; readers and writers do not block each other
TransactionsACID via TransactWriteItems and TransactGetItems: up to 100 actions on up to 100 distinct items, 4 MB aggregate, no indexes, one account and RegionACID across any number of statements and tables
ScalingAutomatic partitioning by partition key; on-demand or provisioned capacityVertical first, plus read replicas; Aurora separates compute and storage
Multi-RegionGlobal tables: 99.999% availability SLA versus 99.99% for single-Region tablesAurora Global Database replicates a cluster to secondary regions
Query languageKey-based API calls; no joinsFull SQL: joins, aggregates, window functions
Cost driverRequest units or provisioned throughput, plus storageInstance size, storage, and I/O
HostingManaged AWS service onlySelf-hosted, Amazon RDS for PostgreSQL, Aurora PostgreSQL-Compatible, or other providers

Data Modeling: Access Patterns First vs Normalized Schema

DynamoDB pushes schema design toward the application's access patterns. A common approach is single-table design: several entity types share one table, and a composite partition key and sort key encode the relationships that would otherwise need joins. Attributes can also be nested maps or lists, which is what makes DynamoDB a document store as well as a key-value store. Nested data is not independently queryable without a matching index or a full scan.

// DynamoDB items: an order and its line item in one table
{
  "PK": "CUSTOMER#123",
  "SK": "ORDER#2026-11-20#001",
  "status": "SHIPPED",
  "total": 48.50
}
{
  "PK": "ORDER#2026-11-20#001",
  "SK": "ITEM#SKU-887",
  "qty": 2
}

PostgreSQL keeps entities in separate normalized tables and expresses relationships with foreign keys, so the planner can join them on demand.

CREATE TABLE customers (
  customer_id SERIAL PRIMARY KEY,
  name TEXT NOT NULL
);

CREATE TABLE orders (
  order_id SERIAL PRIMARY KEY,
  customer_id INT REFERENCES customers(customer_id),
  status TEXT,
  total NUMERIC(10,2)
);

SELECT c.name, o.status, o.total
FROM orders o
JOIN customers c ON c.customer_id = o.customer_id
WHERE o.status = 'SHIPPED';

The DynamoDB approach pays off when access patterns are stable and known ahead of time. The PostgreSQL approach pays off when new questions must be answered without redesigning the schema.

Consistency and Transactions

DynamoDB reads are eventually consistent by default, with strongly consistent reads available as an option on the base table and on local secondary indexes. Global secondary indexes return only eventually consistent results.

DynamoDB supports transactions through TransactWriteItems and TransactGetItems, which AWS documents as providing atomicity, consistency, isolation and durability (ACID) for up to 100 actions on up to 100 distinct items, with a 4 MB aggregate size limit, in a single call. A transaction cannot target the same item twice, cannot be performed using indexes, and must stay within one AWS account and Region. That last limit matters for data modeling: if your access pattern relies on a secondary index, the transaction has to go through the base table.

To read items changed by a transaction safely, use TransactGetItems on all the relevant items together. You then see either all changes from a completed transaction or none of them.

PostgreSQL provides ACID transactions by default and uses multi-version concurrency control (MVCC), so readers and writers do not block each other for ordinary operations. A transaction can span any number of statements and tables, with foreign keys and check constraints enforced by the database.

-- PostgreSQL: multi-statement transaction
BEGIN;
UPDATE accounts SET balance = balance - 100 WHERE id = 1;
UPDATE accounts SET balance = balance + 100 WHERE id = 2;
COMMIT;

If the database itself must enforce complex, multi-table invariants, PostgreSQL is the more natural fit. DynamoDB transactions suit smaller, well-defined operations such as updating an order and decrementing inventory in one call.

Scaling, Capacity Modes and Multi-Region

DynamoDB partitions data across storage nodes by partition key, automatically. Capacity is either on-demand, where the table scales to match traffic without pre-provisioning, or provisioned, with optional auto scaling. The main design risk is a poorly chosen partition key that creates a hot partition and limits throughput regardless of overall table capacity.

For multi-region deployments, DynamoDB global tables replicate a table across two or more AWS Regions (one replica per Region) in one of two consistency modes chosen at creation and fixed thereafter: multi-Region eventual consistency (the default) or multi-Region strong consistency. Global tables carry a 99.999% availability SLA, compared to 99.99% for single-Region tables.

  • Eventual consistency mode: if the same item is modified in several Regions at once, DynamoDB resolves the conflict with last-writer-wins, using the latest internal timestamp per item. Design writes so concurrent cross-Region updates to one item are either rare or safe to overwrite.
  • Strong consistency mode: choose it when cross-Region reads must never see stale data.
  • Version: AWS recommends global tables version 2019.11.21 (Current) over 2017.11.29 (Legacy), since it is more flexible, more efficient and consumes less write capacity. Use the current version for new global tables.

PostgreSQL scales vertically first: larger instances handle more load up to a point, and read-heavy workloads can add read replicas. Amazon Aurora PostgreSQL-Compatible separates compute from a distributed, replicated storage layer, which improves storage scaling and failover compared with standard RDS PostgreSQL. Aurora Global Database replicates a cluster to secondary regions for disaster recovery and regional reads. Write-heavy horizontal scaling beyond a single primary usually means sharding or extensions built on top of PostgreSQL, not a built-in equivalent of DynamoDB's automatic partitioning.

Query Flexibility and Indexing

DynamoDB queries are built around the primary key and two kinds of secondary indexes: local secondary indexes, defined at table creation and sharing the table's partition key, and global secondary indexes, which can be added later with an independent partition key and sort key. There are no joins and no general ad hoc query engine. Filtering beyond the key or an index requires a scan, which the service allows but which does not scale like key-based queries.

PostgreSQL supports the full range of SQL: joins across any number of tables, aggregates, window functions, and subqueries. Its indexing goes beyond B-tree to include GIN for full-text search and JSONB containment and GiST for geometric and range types. Extensions such as PostGIS (spatial data) and pgvector (similarity search) add more.

  • Pick DynamoDB when the complete set of queries is known and each maps to a key or index lookup.
  • Pick PostgreSQL when analysts, reporting tools, or evolving requirements need queries nobody anticipated at schema design time.

Cost Model and Operational Overhead

DynamoDB's cost model is request-based. On-demand capacity bills for the read and write requests consumed. Provisioned capacity bills for reserved throughput whether or not it is fully used, with auto scaling to adjust it. Storage is billed separately. AWS operates the entire service, so there is no patching, instance sizing, or backup infrastructure to manage.

Transactions have no extra enablement fee, but DynamoDB performs two underlying reads or writes for every item in a transaction: one to prepare and one to commit. A transactional write therefore costs roughly double a normal one. Reserve transactions for operations that need all-or-nothing behavior.

PostgreSQL's cost, whether self-hosted or managed through RDS or Aurora, is driven mainly by instance size (compute and memory), storage volume, and I/O rather than per-request units. Managed PostgreSQL still requires choices about instance class, storage type, and backup retention, though the provider handles patching and failover. Self-hosting adds the full burden of provisioning, patching, backups, and high availability.

Because the two cost structures are shaped differently (per request versus per instance), model your expected request rate and data volume against current provider pricing pages rather than relying on general comparisons.

Coexistence and Migration: Aurora and RDS PostgreSQL

DynamoDB and PostgreSQL rarely replace each other cleanly, because their data models solve different problems. The common pattern is coexistence: DynamoDB handles high-throughput, access-pattern-driven paths such as session state or event streams, while Aurora PostgreSQL-Compatible or RDS for PostgreSQL holds the relational core, such as billing records, catalog data, or anything that needs reporting and joins.

Moving data between the two generally requires custom extraction and transformation, since a single-table DynamoDB design does not map directly onto normalized relational tables. DynamoDB Streams can feed consumers that write into PostgreSQL for analytics or search, which is lighter than a full migration. One caveat: transaction changes propagate only gradually to global secondary indexes, streams and backups. Stream records from one transaction can appear at different times and interleave with records from other transactions, so a consumer must not assume transaction atomicity or ordering. Make downstream writes idempotent and tolerant of reordering.

Choosing Aurora over standard RDS for PostgreSQL mainly comes down to storage architecture and failover characteristics. Both use the standard PostgreSQL wire protocol and SQL dialect, so an application built against one generally runs against the other with configuration changes rather than code changes.

Common questions

Can DynamoDB do joins like PostgreSQL?

No. DynamoDB has no join operator. Relationships that would be joins in PostgreSQL are modeled ahead of time by co-locating related items under the same partition key, often in a single-table design.

Is DynamoDB ACID compliant?

For transactions, yes. TransactWriteItems and TransactGetItems provide atomicity, consistency, isolation and durability for up to 100 actions on up to 100 distinct items (4 MB aggregate) per call, within one AWS account and Region. This is narrower than PostgreSQL's multi-statement transactions, which can span any number of tables.

Can I use PostgreSQL and DynamoDB together in the same application?

Yes, and it is a common pattern. Use DynamoDB for high-throughput, access-pattern-specific data and PostgreSQL (via Aurora or RDS) for relational data that needs joins, reporting, or complex transactions. If you feed PostgreSQL from DynamoDB Streams, do not assume stream records preserve transaction ordering.

What is the difference between on-demand and provisioned capacity in DynamoDB?

On-demand capacity scales automatically to match traffic without pre-set throughput and is billed by requests consumed. Provisioned capacity reserves a set read and write throughput, optionally adjusted by auto scaling, and is billed for the reserved amount.

Are DynamoDB global tables strongly consistent?

Only if you choose that mode. Global tables offer multi-Region eventual consistency (the default, with last-writer-wins conflict resolution) or multi-Region strong consistency. The mode is set at creation and cannot be changed afterward.

Sources

  1. Amazon DynamoDB Developer Guide: Transaction APIs
  2. Amazon DynamoDB Developer Guide: Transactions
  3. Amazon DynamoDB Developer Guide: Global tables

About this page

Last reviewed November 27, 2026 by the Nine Bits editors. Read our editorial policy or report an error.