Is there any way of speeding up this query:
return _database.Countries
.Include("Accounts")
.Where(country => country.Accounts.Count > 0)
.ToList();
There are about 70 accounts and 70 Countries, this query takes about 1.5 seconds to execute which is quite long.
EDIT: _database is an EntityFramework model
You could try changing the
Whereclause to:… but really your first port of call should be a database profiler. Look at the generated query, and put it into your favourite profiler. Check indexes etc as you would any other SQL query.
Once you’ve worked out why the generated SQL is slow and what you’d like the SQL to look like, then you can start working out how to change your query to generate that SQL.