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...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help