how are you? 

I know there are plenty of questions and answers about it, but my case is quite particular because I dont have large arrays to intersect. I am implementing a search method that receives a search object and, using linq, searchs into the DB (I am using EF 6 with code first).

* So, I have the following entities in the DB with these columns:

-*User*: userId (int), name (string).

-*UserFeatures*: userId (int), featuresId (short).

-*Features*: featuresId (short), description (string).
* My search object is like this:

{
 "name":"Friedrich Wilhelm",
 "features": [1,2,3,4]
}
* My linq query is like this (the idea is to get all the users that match the features the logged user is looking for).

context.User.Where(u => 
userToSearch.features.Except(u.UserFeatures.Select(uf => 
uf.featuresId))).Any()==false).toListAsync();

This works fine, but it takes 30 seconds aprox. I have 30k users in the DB but each user has around 4 and 5 features each.

I already try using hashset, but as the feature collections are not big, makes no difference. The problem is maybe that I have 30k users with 5 features each. So that means about 150k iterations.

Do you have any idea how i can improve this? In the query I have also another conditions. If I delete the one with the features, the query is much faster (around 4 seconds to run. I am implementing also Paginations -Take, skip, etc.).