Skip to content

feat(multi-keys-gsi): consolidate all SGIs into one#14

Merged
hackmajoris merged 2 commits into
mainfrom
infra/consolidates-gsis
Dec 14, 2025
Merged

feat(multi-keys-gsi): consolidate all SGIs into one#14
hackmajoris merged 2 commits into
mainfrom
infra/consolidates-gsis

Conversation

@hackmajoris
Copy link
Copy Markdown
Owner

Optimize DynamoDB Design: Reduce GSIs from 3 to 1

Summary

Restructured DynamoDB table design to use EntityType as partition key and consolidated skill GSIs, reducing infrastructure costs by eliminating 2 GSIs while maintaining optimal query performance.

Changes Made

Infrastructure (CDK)

  • Main Table: Changed from entity_id (PK) to EntityType (PK) + entity_id (SK)
  • Removed GSIs: Eliminated ByEntityType and BySkillLevel GSIs
  • Consolidated GSI: BySkill now handles both skill-only and skill+level queries using composite sort keys

Database Layer

  • Updated all GetItem/DeleteItem operations to use both EntityType and entity_id keys
  • Modified Query operations to use main table for entity type queries (no GSI needed)
  • Consolidated skill queries to use single BySkill GSI with multi-key sort structure

Model Updates

  • Added composite sort key field SkillCompositeSort to UserSkill model
  • Updated SetKeys() methods to build composite keys for GSI queries

amazon-q-developer[bot]

This comment was marked as off-topic.

@hackmajoris hackmajoris merged commit 680dbed into main Dec 14, 2025
1 check passed
@hackmajoris hackmajoris deleted the infra/consolidates-gsis branch December 14, 2025 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant