Enhance query performance by applying AsSplitQuery to multiple handlers and loaders for Channels and ScheduleTemplates, improving efficiency in data retrieval and reducing unnecessary data duplication in queries.
This commit is contained in:
@@ -18,6 +18,8 @@ public sealed class GetShowQueryHandler(IAppDbContext dbContext)
|
||||
.Shows.AsNoTracking()
|
||||
.Include(s => s.Episodes)
|
||||
.Include(s => s.Genres)
|
||||
// Сиблинги: серии × жанры перемножились бы в одном запросе (см. ListShowsQueryHandler).
|
||||
.AsSplitQuery()
|
||||
.FirstOrDefaultAsync(s => s.Id == query.Id, cancellationToken);
|
||||
if (show is null)
|
||||
return Result.Failure<ShowDto>(ShowErrors.NotFound);
|
||||
|
||||
@@ -17,6 +17,9 @@ public sealed class ListShowsQueryHandler(IAppDbContext dbContext)
|
||||
.Shows.AsNoTracking()
|
||||
.Include(s => s.Episodes)
|
||||
.Include(s => s.Genres)
|
||||
// Серии и жанры — сиблинги: одним запросом это честное перемножение (сериал на 200 серий
|
||||
// с тремя жанрами даёт 600 строк вместо 203). Разделяем.
|
||||
.AsSplitQuery()
|
||||
.Where(s =>
|
||||
query.Interstitials
|
||||
? s.Kind == ShowKind.Interstitial
|
||||
|
||||
Reference in New Issue
Block a user