虽然后台慢不是不能用,但是销售一直在反映操作很慢让优化。销售后台时间选择器粒度只精确到天,不知道这个地方是不是可以做什么效果比较好的优化。
正常情况下日订单在五百万左右。这个页面需要显示每个 SKU 在不同阶段(状态)的订单的数量。有考虑过用 Redis 但是我们的 Redis 是单机的只用来缓存,经常 flushall 。再单独加一台 Redis 觉得不划算
return Ok(dbContext.Orders.Where(x => x.CreatedAt >= DateTimeOffset.FromUnixTimeMilliseconds(queryForm.StartDate) &&
x.CreatedAt <= DateTimeOffset.FromUnixTimeMilliseconds(queryForm.EndDate))
.Include(x => x.Sku).Where(x => x.Sku != null)
.GroupBy(o => o.SkuId)
.Select(g => new
{
SkuId = g.Key,
SkuName = g.Select(o => o.Sku.TitleEng).FirstOrDefault(),
Delivering = g.Count(o => o.Status == (int)OrderStatusEnum.Delivering),
Cancelled = g.Count(o => o.Status == (int)OrderStatusEnum.Cancelled),
InProcess = g.Count(o => o.Status == (int)OrderStatusEnum.InProcess),
InReview = g.Count(o => o.ReviewTasks.Any(t => t.Pending && t.Result == false)),
Total = g.Count()
})
.ToList());
能想到的索引都已经加了
[Index(nameof(Status))]
[Index(nameof(Input))]
[Index(nameof(SkuId))]
[Index(nameof(UserId))]
[Index(nameof(CreatedAt))]
[Index(nameof(UpdatedAt))]
[Index(nameof(OrderTag))]
[Index(nameof(SendPending))]
[Index(nameof(OrderSource))]
[Index(nameof(UserId), nameof(SkuId), nameof(FromMobileApp))]
[Index(nameof(UserId), nameof(Status))]
[Index(nameof(SkuId), nameof(Status))]
[Index(nameof(Status), nameof(RiskyScore))]
[Index(nameof(UserId), nameof(Input))]
[Index(nameof(UserId), nameof(InputTailing))]
public class Order : BaseEntity
{ ... }
|