It ain't this simple !!
A single damn SELECT query is not enough for your application !
Imagine that you're building a SaaS that requires username lookups every time a user signs-in.
Are you really gonna use
SELECT username FROM user WHERE username IS "ateebHussain";
Seriously??
That's not how tech giants do this, you are gonna rack up AWS bills just for one user when you have BILLIONS of records sitting in one DB TABLE.
Tech Giants, and other applications user a number of techniques/algorithms to handle username lookups efficiently with as much less time as possible.
These Involves:
- Redis Hashmaps
- Trie Structures
- B+ Trees
- Bloom Filters
Many a companies use a combination of theses for more efficient lookups and less false positives.
In the next post, I am gonna cover detailed implementation plan and PROS and CONS for each algorithm depending on your edge-case.
P.S. I'm still using username @unique with PostgreSQL for a 10k users System Design 😋
What was your first, "This ain't right" moment with usernames?
Top comments (0)