0
0
DynamoDBquery~10 mins

Index capacity and cost in DynamoDB - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Index capacity and cost
Create Table
Add Index (GSI or LSI)
Write Operation
Calculate Capacity Units
Calculate Cost
Billing Based on Usage
This flow shows how adding an index affects capacity units and cost in DynamoDB, starting from table creation to billing.
Execution Sample
DynamoDB
Create table with 5 WCU and 5 RCU
Add a Global Secondary Index (GSI) with 2 WCU and 2 RCU
Write 10 items to table (propagates to GSI)
Read 5 items from table
Read 5 items from GSI
Calculate total WCU and RCU consumed
Calculate cost based on capacity units
This example shows how writing data to a table with a GSI consumes capacity units on both table and GSI, and reads consume separately, affecting cost.
Execution Table
StepActionTable WCU UsedGSI WCU UsedTotal WCUTable RCU UsedGSI RCU UsedTotal RCUCost Impact
1Create table with 5 WCU and 5 RCU000000No usage cost yet
2Add GSI with 2 WCU and 2 RCU000000No usage cost yet
3Write 10 items to table (propagates to GSI)101020000Consumes 10 WCU on table + 10 WCU on GSI
4Read 5 items from table101020505Consumes 5 RCU on table
5Read 5 items from GSI1010205510Consumes 5 RCU on GSI
6Calculate total capacity1010205510Total: 20 WCU and 10 RCU consumed
7Billing------Charged for 20 WCU and 10 RCU usage (on-demand mode)
💡 Execution stops after billing calculation based on capacity units used.
Variable Tracker
VariableStartAfter Step 3After Step 4After Step 5Final
Table WCU Used010101010
GSI WCU Used010101010
Total WCU020202020
Table RCU Used00555
GSI RCU Used00055
Total RCU0051010
Key Moments - 3 Insights
Why does writing to a table with GSI consume write capacity units on both?
Writes to the table automatically propagate to the GSI, which maintains its own copy of data, consuming WCU on table and GSI separately (see execution_table row 3).
Does reading from a GSI consume read capacity units from the main table?
No, reading from a GSI consumes RCU from the GSI's provisioned/on-demand capacity only (see execution_table row 5).
How is the total cost calculated when using indexes?
In on-demand mode, cost is based on the sum of capacity units actually consumed by the table and all indexes (see execution_table rows 6-7).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the total write capacity units used after step 3?
A10
B20
C0
D5
💡 Hint
Check the 'Total WCU' column at step 3 in the execution_table.
At which step does reading from the GSI first consume read capacity units?
AStep 5
BStep 4
CStep 3
DStep 6
💡 Hint
Look at the 'GSI RCU Used' column in the execution_table.
If you remove the GSI, how would the total write capacity units after step 3 change?
AIt would stay 20
BIt would become 0
CIt would become 10
DIt would become 5
💡 Hint
Without GSI, writes consume WCU only on the table (10 WCU for 10 items).
Concept Snapshot
DynamoDB indexes (GSI/LSI) have separate capacity units.
Writes to table automatically update GSIs, consuming WCU on table + each GSI.
Reads from table/GSI consume RCU from their respective capacities.
In on-demand mode, billed for consumed units across table + indexes.
Plan indexes carefully to balance query flexibility and cost.
Full Transcript
This visual execution demonstrates DynamoDB index capacity and cost. Create a table, add a GSI—each with their capacity settings. Writing items to the table consumes WCU on both table and GSI since GSIs store data copies. Reads consume RCU separately from table or GSI. Total consumed units sum table + index usage. In on-demand billing, pay for actual consumption. This helps optimize capacity planning and costs.