Scrivio Interview library
DesignAdvanced7 min read · updated 12 November 2026

A product team using DynamoDB now needs ad hoc analytics across all orders (revenue by region, cohort reports). How do you provide this without harming the operational table?

We keep analytics off the operational table entirely: no Scans, because they consume the table's capacity and are slow. Instead we copy the data out, with DynamoDB's point-in-time export to S3 queried by Athena or loaded into a warehouse for daily reports, and with DynamoDB Streams or Kinesis Data Streams feeding a pipeline when the analytics must be fresher. The analytics copy gets its own schema, with single-table items flattened into one table per entity type, and its own governance for personal data, retention and access.

Why this question is asked

DynamoDB tables are designed around a few known access patterns, which is exactly what makes them fast and cheap for the product. Ad hoc analytics is the opposite: questions nobody predicted, over all the data, grouped in ways the keys were never designed for. Interviewers ask this to see whether we protect the operational system while still giving the business its reports. In this answer, we will see why querying the table directly is the wrong move, design a batch path through S3 and a fresher path through streams, reshape single-table items for analysis, and deal with the governance questions that a second copy of customer data raises.

1Why Not Scan the Production Table?

A Scan reads every item in the table, page by page, 1 MB at a time. It is the only way to answer revenue by region from a table keyed by customer and order, because region is not in any key. Let us put a number on it. A 500 GB orders table read with eventually consistent reads costs one read capacity unit per 8 KB, so a full scan consumes about 65 million read units. On a provisioned table, that capacity is taken from the same pool the checkout uses, and throttling starts. On an on-demand table, it is paid for on every report run. Either way, an analyst running a few exploratory queries a day can harm the product and run up a bill.

Scans are also slow, since even a parallel scan must read everything, and DynamoDB has no GROUP BY or joins, so aggregation happens in the client. So the rule is simple: the operational table serves the application, and analytics runs on a copy.

2The Batch Path: Export to S3 and Query It

For reports that can be a few hours old, the simplest path is DynamoDB's export to S3. It requires point-in-time recovery (PITR) to be enabled, and it reads from the continuous backups, not from the table, so it consumes no read capacity and does not affect latency. It writes the table's items as files in DynamoDB JSON or Amazon Ion format. Incremental exports, which write only items changed in a time window, make daily refreshes cheaper than a full export each time.

Java
aws dynamodb export-table-to-point-in-time \
--table-arn arn:aws:dynamodb:eu-west-1:123456789012:table/shop \
--s3-bucket shop-analytics-raw --s3-prefix exports/2026-11-06/ \
--export-format DYNAMODB_JSON
# "ExportStatus": "IN_PROGRESS" -> later "COMPLETED"; files under exports/2026-11-06/data/

A scheduled job, for example with AWS Glue or a Spark job, then converts the export into columnar Parquet files partitioned by date, flattens it into tables, and registers them in a catalog. Analysts query them with Athena using plain SQL, or the job loads them into a warehouse such as Redshift, Snowflake or BigQuery. Revenue by region becomes a GROUP BY that scans compressed columns, not the operational table.

3The Fresher Path: Streaming Changes

When the business needs data within minutes, such as a live sales dashboard, we capture changes as they happen. DynamoDB Streams records every insert, update and delete for 24 hours, and Kinesis Data Streams for DynamoDB is an alternative with longer retention and more consumers. A consumer, a Lambda function or a Kinesis Data Firehose delivery stream, transforms each change and writes it to S3 or directly to a warehouse.

Step throughTwo paths from the operational table to analytics
  1. Operational tableServes the application only
  2. PITR export to S3 / change streamNo read capacity used / near real time
  3. Transform jobFlatten entities, Parquet, partition by date
  4. Analytics storeS3 + Athena, or a warehouse
  5. Reports and ad hoc SQLAnalysts, BI tools

5 layers, from the top down. Step through them one at a time.

The product table never sees an analytics query.

Notice that the stream gives changes, not a table. The pipeline must apply them in order per key and handle deletes, so the analytics store ends up with the current state, or it can keep the full history of changes, which is often more useful for analytics. A common combination is a one-time export to seed the analytics store, followed by streaming to keep it current.

4Reshaping Single-Table Items

Many DynamoDB designs use a single table holding several entity types, with generic key attributes such as PK and SK. That is great for the application and confusing for an analyst. The transform step therefore separates items by type and maps them to one analytics table per entity.

SQL
-- items in the operational table (simplified)
-- PK = CUST#42 SK = PROFILE name, region
-- PK = CUST#42 SK = ORDER#2026-11-06#9f total_cents, status
-- PK = ORDER#9f SK = ITEM#1 sku, qty, price_cents
-- analytics tables after the transform
CREATE TABLE customers (customer_id string, name string, region string);
CREATE TABLE orders (order_id string, customer_id string, order_date date, total_cents bigint, status string);
CREATE TABLE order_items (order_id string, sku string, qty int, price_cents bigint);
SELECT c.region, sum(o.total_cents) / 100.0 AS revenue -- the question that started it
FROM orders o JOIN customers c ON o.customer_id = c.customer_id
WHERE o.order_date >= date '2026-10-01'
GROUP BY c.region;

The analytics schema is defined and versioned separately from the operational model, so the product team can change its keys without breaking reports, as long as the transform is updated. Cohort reports, such as revenue by month of first order, become ordinary SQL with window functions.

5Governance of the Analytics Copy

Copying data creates a second place where customer information lives, and that copy is often accessed by more people than the original. So we decide up front which fields go into it. Personal data such as names, emails and addresses is dropped, masked or pseudonymised in the transform unless a report truly needs it. Access is controlled through the catalog with fine-grained permissions per table and column, and query access is logged.

Retention needs care too. If a customer deletes their account or exercises a right to erasure, the analytics copy must also be cleaned, which is easier when personal data was kept out of it in the first place. Lifecycle rules on the S3 buckets enforce how long raw exports are kept.

6Follow-up questions

Why not add a global secondary index on region for the revenue report?

An index serves a known query pattern for the application, and it costs write capacity on every order write. Ad hoc analytics means the next question will need a different index, and aggregation still happens in the client. Indexes are for the product's access patterns; analytics belongs in a store built for scanning and grouping.

How fresh does the data need to be?

We ask the product team for each report. Daily cohort reports are fine with a nightly incremental export. A live dashboard needs the stream path. Many teams find that a few reports need minutes and most are fine with hours, which keeps the streaming part small.

What about zero-ETL integrations?

Some providers offer managed integrations that replicate DynamoDB into a warehouse or search service without writing a pipeline. They can replace the transform job for simple cases; we still define the schema and governance for the target, and check which regions and features are supported.

7Conclusion

In this answer, we kept analytics away from the operational DynamoDB table because Scans consume its capacity and are slow. We used point-in-time exports to S3, which read from backups, with Athena or a warehouse for batch reports, and DynamoDB Streams or Kinesis Data Streams for fresher data. We flattened single-table items into one analytics table per entity type, and applied governance to the copy: minimal personal data, access control, logging and retention that follows erasure requests.

What to say in the interviewAbout 90 seconds aloud

Open with

The first rule is that analytics never runs on the production table. A Scan reads every item, consumes read capacity from the same pool the application uses, so it can throttle checkout or run up an on-demand bill, and it is slow with no grouping or joins.

Then, if they want more

So I would build a copy. For reports that can be hours old, I would enable point-in-time recovery and use the export to S3, which reads from the backups and costs no table capacity, with incremental exports for daily refreshes.

A Glue or Spark job converts the export to Parquet partitioned by date, and analysts query it with Athena or we load it into a warehouse. If some dashboards need data within minutes, I would add DynamoDB Streams or Kinesis Data Streams feeding a Firehose or Lambda pipeline into the same store, seeded once from an export.

The analytics schema is defined separately: a single-table design with PK and SK items gets flattened by entity type into customers, orders and order items, so revenue by region or cohort reports are plain SQL.

Finally I would treat the copy as a governance question: keep out or pseudonymise personal data unless a report needs it, control access per table and column, log queries, and make sure retention and erasure requests apply to the analytics copy too.

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.
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 product team using DynamoDB now needs ad hoc analytics across all orders (revenue by...": https://scrivio-interview-library.netlify.app/databases/cassandra-and-dynamodb/e7078edb55/