sendou.ink/db-test.sqlite3
Kalle 4bc8033841 Collapse repeated manual badge grants into a count column
TournamentBadgeOwner previously stored manual grants as N identical
rows to represent "this user has this badge N times" — one user had
12,345 duplicate rows for a single badge. This adds a `count` column,
collapses NULL-tournamentId duplicates in the backfill, and rewrites
the BadgeOwner view to expose count via SUM. The table shrinks from
75,596 to 24,204 rows. Also adds an index on TournamentBadgeOwner(userId)
as defense-in-depth for direct lookups, and updates replaceOwners to
dedupe ownerIds at insert time. Profile-page query for the worst-case
user drops from ~4 ms to ~1–2 ms warm.
2026-05-14 18:09:41 +03:00

1.2 MiB