Scrivio Interview library
DesignAdvanced7 min read · updated 12 November 2026

A team wants to move an order service from PostgreSQL to DynamoDB to reduce operational work. What questions would you ask, and what risks would you highlight?

I would start by asking for the full list of access patterns, because DynamoDB serves known key-based queries very well and ad hoc queries, joins and reporting poorly. Then I would highlight the main risks: transactions exist through TransactWriteItems but with item and size limits and higher cost, reporting needs exports or streams into a warehouse, cost depends on request volume and item size and must be modelled with real traffic, and the move creates AWS lock-in. Finally, I would ask for a migration plan with backfill, dual writes or change capture, and verification before cutover. Reducing operational work is a valid goal, but a managed PostgreSQL service may reach it with far less change.

Why this question is asked

"Reduce operational work" is an excellent reason to change something, and DynamoDB does remove almost all of it: no servers, no patching, no failover drills. But an order service built on PostgreSQL relies on relational features in ways the team may not have listed, and finding them after the migration is expensive. Interviewers ask this design question to see whether we can evaluate a proposal for both its benefit and its hidden costs, and whether we know cheaper ways to reach the same goal. In this answer, we will clarify the goal, go through access patterns, transactions, reporting, cost and lock-in one by one with the questions to ask, and end with a migration plan and a recommendation.

1First, What Operational Work Are We Reducing?

Before evaluating DynamoDB, I would ask which operational work hurts today. If it is patching, backups, failover and upgrades of self-managed PostgreSQL, then a managed relational service such as Amazon RDS or Aurora removes most of it while keeping the schema, SQL, transactions and every query the service already has. If it is scaling, such as write volume outgrowing the largest instance, that is a different problem with different answers.

This question matters because a database migration changes the data model, all the queries and every consumer, while a move to a managed service of the same engine changes mostly the connection string. If the goal can be reached with the second, the first needs a stronger reason.

Two ways to reduce operations
OptionRemovesChanges in codeKeeps
Managed PostgreSQL (RDS, Aurora)patching, backups, failoverlittleSQL, joins, transactions, reports
DynamoDBnearly all operations, scalingdata model, every querykey-value access at any scale

2Question 1: What Are the Access Patterns?

DynamoDB is efficient only for queries that start from a key: get an item by its primary key, or query one partition key's items by a sort key range. Every other query needs a global secondary index designed in advance, or a Scan of the whole table. So I would ask the team to list every query the order service and its consumers run today, including the ones in admin screens, support tools, scheduled jobs and nightly exports. The database's query log is the honest source, since it shows queries nobody remembers writing.

A typical order service has a handful of key-based patterns that fit perfectly, such as get order by id, list a customer's orders by date, and list orders by status for the warehouse with a sharded index. It also has ad hoc ones: support searching by email and partial address, finance filtering by payment method and amount, product asking new questions every quarter. Those are joins and filters on arbitrary columns, which DynamoDB does not do. Each one needs an index, a copy in another store, or a new design.

3Question 2: How Much Do We Rely on Transactions?

PostgreSQL lets the service change an order, its lines, a stock reservation and an outbox event in one transaction, with constraints such as foreign keys and unique order numbers enforced by the database. DynamoDB has transactions too: TransactWriteItems groups writes to multiple items atomically, with conditions.

Java
TransactWriteItems [
Put pk=ORDER#o-1001 sk=META condition: attribute_not_exists(pk) // unique order
Update pk=PRODUCT#p-7 sk=STOCK SET qty = qty - 2 condition: qty >= 2
Put pk=ORDER#o-1001 sk=LINE#1
]
// all or nothing; limits: up to 100 items and 4 MB per transaction (check current limits)
// each transactional write consumes about twice the write capacity of a normal write

They are useful but more limited: a bounded number of items, no reads inside the same transaction that decide what to write next beyond conditions, double capacity cost, and conflicts that fail the whole transaction under contention. There are no foreign keys, and uniqueness of anything other than the primary key needs an extra item per unique value. I would ask the team to list the invariants the current schema enforces and show how each one is kept in the new design.

4Question 3: Where Does Reporting Go?

Reports on orders, such as revenue by region, refunds per week or cohort analysis, are aggregations and joins over many items, which DynamoDB is not designed for. After the move, reporting must run elsewhere: DynamoDB Streams or Kinesis can deliver changes to a pipeline, and the table can be exported to S3 for querying with an analytics engine or loading into a warehouse. That is new infrastructure with its own cost and owners, and the delay of the reporting data becomes a business decision. I would ask who builds and owns that pipeline, and whether finance and analytics teams have agreed to the change in how they get data.

5Question 4: What Will It Cost?

DynamoDB pricing depends on requests and item size rather than servers. A write unit covers a write of up to 1 KB, and a read unit covers a strongly consistent read of up to 4 KB, or two eventually consistent ones. Every GSI adds the cost of writing the indexed copy. So I would ask for a cost model from real traffic: number of reads and writes per order through its life, item sizes, number of indexes, and peak versus average. For example, if an order with lines is 3 KB and is written 5 times during its life with two GSIs, that is about 5 x 3 x 3 = 45 write units per order before reads, which at a few million orders a month becomes a real number to compare with the managed PostgreSQL bill. On-demand mode is simple but more expensive per request at steady high load than provisioned capacity with auto scaling.

6Question 5: Lock-In and the Migration Plan

DynamoDB is available only on AWS, and a single-table design is specific to it, so moving away later would be another full migration. That may be acceptable for a company committed to AWS, but it should be a conscious decision recorded with the reasons.

If we proceed, the migration needs a plan. A common approach is to keep PostgreSQL as the source of truth while change data capture or dual writes populate DynamoDB, backfill historical orders in batches, then verify by comparing counts and checksums and by shadow reading, sending real read requests to both and comparing the responses. Reads switch first, then writes, with a rollback path at each step. Dual writes from the application are fragile, since one can succeed and the other fail, so change capture with an idempotent loader is usually safer during the transition.

Step throughA staged migration
  1. Design keys and indexes from the access-pattern list
  2. Stream changes from PostgreSQL to DynamoDBCDC, idempotent loader
  3. Backfill history in batches
  4. Shadow reads match?
    YesSwitch reads to DynamoDBNoFix model or loader, repeat
  5. Switch writes, keep reverse sync for rollback
  6. Retire PostgreSQL after a safe period

6 steps in order. Play them, or step through them one at a time.

7Follow-up questions

When would you support the move to DynamoDB?

When the access patterns are few, stable and key-based, invariants fit within its transaction limits, reporting already runs from a warehouse, the cost model is acceptable, and the scale or operational benefit clearly exceeds what managed PostgreSQL offers. A high-volume order event store or a cart service often meets that bar.

Could we move only part of the service?

Yes, and that is often the best answer: keep the transactional order core in managed PostgreSQL and move a high-volume, key-based part such as order tracking events or carts to DynamoDB, fed by events.

8Conclusion

In this answer, we evaluated a move from PostgreSQL to DynamoDB by first asking which operational work hurts, since managed PostgreSQL may remove it with little change. We then asked for every access pattern, because DynamoDB serves known key-based queries and not ad hoc ones or joins; listed the invariants that transactions and constraints enforce today against the limits of TransactWriteItems; planned reporting through streams or exports to a warehouse; modelled cost from request volume and item size; and recorded the AWS lock-in, with a staged migration of change capture, backfill and shadow-read verification if we proceed.

What to say in the interviewAbout 90 seconds aloud

Open with

My first question would be which operational work we want to remove. If it is patching, backups and failover, a managed PostgreSQL like RDS or Aurora removes most of that while keeping the schema, SQL and transactions, and that is a far smaller change than a new data model.

Then, if they want more

If we still want DynamoDB, I would ask for the full list of access patterns, taken from the query log rather than memory, because DynamoDB is great for get by key and query by partition and sort key, but ad hoc queries, joins and arbitrary filters need an index designed in advance or a scan.

Support and finance queries are usually where this breaks. Second, transactions and constraints: TransactWriteItems is all-or-nothing across items with conditions, but it has item and size limits, costs about double, and there are no foreign keys or secondary unique constraints, so I want every invariant mapped to the new design.

Third, reporting has to move to a warehouse fed by streams or S3 exports, which is new infrastructure with an owner. Fourth, cost: it depends on requests and item size, plus every GSI's writes, so I want a model built from real traffic. Fifth, lock-in to AWS, which should be a conscious choice.

And if we go ahead, a staged migration: change capture from PostgreSQL, backfill, shadow reads compared, reads then writes switched, with rollback at each step.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Spring Data reference
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "A team wants to move an order service from PostgreSQL to DynamoDB to reduce operational...": https://scrivio-interview-library.netlify.app/databases/spring-data-nosql/0c257229e9/