They know, based on the first few letters of your name, roughly where to start looking instead of searching through all the shelves. A database index works on essentially the same principle—it lets the database quickly narrow down where to look instead of scanning every row.