0

I search 100,000 users search in Asp.Net with UserName and NormalizedUserName. But one thing I noticed is that searching with NormalizedUserName is faster.

 await _context.Users.Where(u => u.NormalizedUserName == username).FirstOrDefaultAsync();
 await _context.Users.Where(u => u.UserName == username).FirstOrDefaultAsync();

enter image description here

Markus Meyer
  • 3,327
  • 10
  • 22
  • 35
  • In the answer on the marked duplicate: "They are persisted in the database in order be able to create index on them, thus making the lookups by the normalized user name and email sargable." – Igor Aug 10 '22 at 18:05

1 Answers1

2

The default configuration has an index on NormalizedUserName.
See the documentation

b.HasIndex(u => u.NormalizedUserName).HasName("UserNameIndex").IsUnique();
pfx
  • 20,323
  • 43
  • 37
  • 57