Browse Source

perf(mongodb): optimize event inbox query for better index utilization

Replace negation operator (!x.Processed) with equality comparison (x.Processed == false)
in MongoDbContextEventInbox.GetWaitingEventsAsync to improve MongoDB query performance.
This change converts the $ne operator to an equality match, allowing better index
utilization and more efficient queries, especially for large collections.
pull/22925/head
Gilcemir 1 year ago
parent
commit
c4064aecfa
  1. 2
      framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/MongoDbContextEventInbox.cs

2
framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/MongoDbContextEventInbox.cs

@ -64,7 +64,7 @@ public class MongoDbContextEventInbox<TMongoDbContext> : IMongoDbContextEventInb
var outgoingEventRecords = await dbContext
.IncomingEvents
.AsQueryable()
.Where(x => !x.Processed)
.Where(x => x.Processed == false)
.WhereIf(transformedFilter != null, transformedFilter!)
.OrderBy(x => x.CreationTime)
.Take(maxCount)

Loading…
Cancel
Save