I have a query for a details-view of a meeting, which has a lot of included related data:
Meeting meeting = await db.Meetings
.Include(a => a.Agenda)
.ThenInclude(s => s.Speakers)
.ThenInclude(u => u.User)
.Include(s => s.Summonings)
.ThenInclude(u => u.User)
.Where(p => p.Id == parsedMeetingId)
.FirstOrDefaultAsync();
I have set up a Stopwatch
, and these are the results for the last six runs (SS:MS):
25:23
25:04
24:36
00:03 // What happened here, I really don't know!
25:25
25:06
There is not much data in the db; Only one Meeting
with 4 Summoning
s, an Agenda
of 11 AgendaItem
s, and only 1 Speaker
in 1 AgendaItem
.
My dev PC is a rather modest AMD laptop with only 8 GB RAM, running Windows 10. At the time of testing, I was only running Visual Studio and Chrome.
(How) can the query or model design be improved?
Where can I look for other bootle necks?
The models:
public class Meeting
{
public Guid Id { get; set; }
public Guid OwnerId { get; set; }
public Guid ModeratorId { get; set; }
public Guid ReportWriterId { get; set; }
public string Title { get; set; }
public List<AgendaItem> Agenda { get; set; }
public List<MeetingSummoning> Summonings { get; set; }
public ApplicationUser Owner { get; set; }
public ApplicationUser Moderator { get; set; }
public ApplicationUser ReportWriter { get; set; }
// Some more properties ...
}
public class AgendaItem
{
public Guid Id { get; set; }
public string Title { get; set; }
public Guid MeetingId { get; set; }
public Meeting Meeting { get; set; }
public List<Speaker> Speakers { get; set; }
// Some more properties ...
}
public class MeetingSummoning
{
public Guid Id { get; set; }
public Guid MeetingId { get; set; }
public Guid UserId { get; set; }
public Meeting Meeting { get; set; }
public ApplicationUser User { get; set; }
}
public class Speaker
{
public Guid Id { get; set; }
public DateTime Requested { get; set; }
public DateTime? Started { get; set; }
public DateTime? Finished { get; set; }
public bool IsCurrent { get; set; }
public Guid? ReplyToSpeakerId { get; set; }
public Speaker ReplyToSpeaker { get; set; }
public Guid AgendaItemId { get; set; }
public AgendaItem AgendaItem { get; set; }
public Guid UserId { get; set; }
public ApplicationUser User { get; set; }
}
public class ApplicationUser : IdentityUser<Guid>
{
public string FirstName { get; set; }
public string LastName { get; set; }
public List<MeetingSummoning> MeetingSummonings { get; set; }
public List<Meeting> OwnedMeetings { get; set; }
public List<Meeting> ModeratedMeetings { get; set; }
public List<Meeting> ReportedMeetings { get; set; }
// Lots more properties ...
}