Pagination
DynamoDB returns results in pages. Use .limit() and .start_from() for manual pagination, or .fetch_all() and .count() for automatic multi-page iteration.
Manual Pagination
# Manual pagination
page1 = orders.query(user_id="usr_123").limit(10)
for order in page1:
print(order)
if page1.last_key:
page2 = orders.query(user_id="usr_123").limit(10).start_from(page1.last_key)
Auto-pagination
# Auto-pagination — fetches all pages into a single result
all_orders = orders.query(user_id="usr_123").fetch_all()
# Auto-pagination with a cap
first_1000 = orders.query(user_id="usr_123").fetch_all(max_items=1000)
Count Across All Pages
# Count across all pages (uses Select=COUNT, does not fetch items)
total = orders.query(user_id="usr_123").filter(status__eq="PENDING").count()