大量消息收件箱完成第一层性能优化

This commit is contained in:
2026-08-10 17:09:51 +08:00 Unverified
parent 7731a343d7
commit e4f1d88ca1
6 changed files with 7024 additions and 4 deletions
@@ -1475,8 +1475,11 @@ public sealed class AppDbContext(DbContextOptions<AppDbContext> options)
entity.Property(x => x.Title).HasMaxLength(200);
entity.Property(x => x.Content).HasColumnType("longtext");
entity.Property(x => x.LinkUrl).HasMaxLength(300);
entity.HasIndex(x => new { x.UserId, x.IsRead });
entity.HasIndex(x => new { x.UserId, x.Category, x.CreatedAt });
// Each inbox query starts with its recipient. Keep the selected
// sort fields in the index so large inboxes do not need a filesort.
entity.HasIndex(x => new { x.UserId, x.CreatedAt, x.Id });
entity.HasIndex(x => new { x.UserId, x.IsRead, x.CreatedAt, x.Id });
entity.HasIndex(x => new { x.UserId, x.Category, x.CreatedAt, x.Id });
entity.HasIndex(x => x.MessageDispatchId);
entity.HasIndex(x => x.CreatedAt);
entity.HasOne(x => x.MessageDispatch)