Like most analytics platforms, Userbird partitions data by date.
Each visitor is assigned a session_id
that expires at the end of the day—effectively tying every session to a single partition.
We wanted to build a Session Explorer: a tool to let users inspect individual sessions by session_id
. But this raises a key question:
If data is partitioned by date, how can we retrieve a session without scanning every partition?

The Solution: Compound Keys#
Inspired by DynamoDB best practices, we embedded the partition key (the date) directly into the session_id
. This turns the ID itself into a compound key, pointing to both the partition and the specific record.
For example:
20250611f200a47071395f12ce64d206
The first 8 characters (20250611
) represent the date. This has two benefits:
- It tells us exactly which partition to scan.
- It makes session IDs sortable by date, which is useful for time-based queries.
With this structure, fetching a session becomes efficient: we can directly query the relevant partition using the embedded date, with no full-table scan required.
Ready to Try Privacy-First Analytics?
See how Userbird can give you powerful insights without compromising user privacy. No cookies, no tracking consent needed, fully GDPR compliant.