accesspatterns.dev

One index, many questions

Different entity types share generic index keys, so one index serves several access patterns.

Why

Here one table holds projects and tasks, and one index, GSI1, serves both. The trick is generic key names: projects write OWNER#ada into gsi1pk, tasks write STATUS#doing into the same attribute.

So one index answers 'Ada's projects' and 'tasks in progress': two access patterns, two entity types, one set of index keys. This overloading is the heart of single-table design.

Generic, overloaded keys let one index do the work of many. That is how a single table serves a whole application.

Workspace

These rows are real and already here. Running an operation against them downloads a DynamoDB-compatible engine, about 850 KB, and executes it in this tab.

Try an example

On GSI1, project items set gsi1pk to OWNER#ada. So this Query returns Ada's projects.

pk(pk)
sk(sk)
name
gsi1pk
gsi1sk
title
PROJECT#web
PROJECT#webS
WebsiteS
OWNER#adaS
PROJECT#webS
PROJECT#web
TASK#1S
STATUS#doingS
TASK#1S
Hero redesignS
PROJECT#web
TASK#2S
STATUS#todoS
TASK#2S
Write copyS
PROJECT#web
TASK#3S
STATUS#doneS
TASK#3S
Fix the footerS
PROJECT#api
PROJECT#apiS
APIS
OWNER#adaS
PROJECT#apiS
PROJECT#api
TASK#4S
STATUS#doingS
TASK#4S
Add paginationS
PROJECT#api
TASK#5S
STATUS#todoS
TASK#5S
Rate limitingS
PROJECT#api
TASK#6S
STATUS#todoS
TASK#6S
WebhooksS
PROJECT#mobile
PROJECT#mobileS
Mobile appS
OWNER#graceS
PROJECT#mobileS
PROJECT#mobile
TASK#7S
STATUS#doingS
TASK#7S
Push notificationsS
PROJECT#mobile
TASK#8S
STATUS#todoS
TASK#8S
Offline modeS
PROJECT#mobile
TASK#9S
STATUS#doneS
TASK#9S
App iconS
PROJECT#data
PROJECT#dataS
Data platformS
OWNER#samS
PROJECT#dataS
PROJECT#data
TASK#10S
STATUS#doingS
TASK#10S
Nightly exportS
PROJECT#data
TASK#11S
STATUS#todoS
TASK#11S
Backfill ordersS
PROJECT#data
TASK#12S
STATUS#doneS
TASK#12S
Archive logsS
PROJECT#docs
PROJECT#docsS
Docs siteS
OWNER#adaS
PROJECT#docsS
PROJECT#docs
TASK#13S
STATUS#todoS
TASK#13S
API referenceS
PROJECT#docs
TASK#14S
STATUS#doingS
TASK#14S
QuickstartS

Run an operation to see the raw engine response.

table Workspacekeys pk / skitems 19