µs Human-Readable IDs: A Performance Journey
dev.to·2h·
Discuss: DEV

It Started With Someone Else’s Terrible Code

There I was, innocently profiling our account management system, trying to figure out why creating a new organization took forever. What I found made me simultaneously frustrated and fascinated.

The code was generating organization slugs. Simple enough, right? Except it was doing something spectacularly inefficient: it would fetch every single organization from the database, count them in memory, and then generate a slug like personal-organization-47. For the 47th organization. By fetching all 46 previous ones. And filtering by a regex.

Not only was this painfully slow, but it was also racing against itself. Two simultaneous requests? Congratulations, you might get duplicate slugs.

The “Good Enough” Fix

I needed something…

Similar Posts

Loading similar posts...