We have the following piece of code:
public async Task<bool> AreConsumerIdAndSecretExistAsync(AuthenticateConsumerRequest request)
{
return await _pplEntities.ApiConsumers.AnyAsync(ac =>
ac.ConsumerId.Equals(request.ConsumerId) && ac.ConsumerSecret.Equals(request.ConsumerSecret));
}
This queries a table containing only three rows of data.
For some reason, it sometimes takes a long time to execute the above method.
It's not the only place, where this issue occurs. It seems like in other places that run multiple SQL queries, it takes a long time to run the first queries, and other queries seem to be problem free. If I run the application locally, it's very fast, except for the first query.
Below is a picture of a New Relic trace showing how slow the application is. In other environments, we experience that the whole request takes upwards of 15 seconds; it's very confusing.
We're running on .NET 4.6.1.