The deserializing in passport js

As you can see the marked statement, it’s obvious a database is used in the deserialization.

I was wondering why a database? Doesn’t it affect the performance? Aren’t there alternatives to it?