From the notes of week 9 - lecture, continued,
Presumably, username is unique, so why bother with an id column? An id is only 32 bits because it’s an integer, whereas username is a variable-length string. Comparing strings is not as fast as comparing integers, so lookups by id will be faster than lookups by username.
I understand the idea of an id (a number) being of a fixed-length while a username (a string) is of a variable-length and thus, id comparisons will be faster most of the time.
But how do we get the id at the first place to use it in searching?
I know we can create a separate unique column to store IDs, but I mean when we pass the username/password combination, what does that have to do with searching with using an id? How do we make use of the advantage of searching with an ID without knowing it first?