From c4064aecfae51a9aa77ab1b5ffaac9e54032913e Mon Sep 17 00:00:00 2001 From: Gilcemir Date: Fri, 16 May 2025 16:51:20 -0300 Subject: [PATCH] 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. --- .../Abp/MongoDB/DistributedEvents/MongoDbContextEventInbox.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/MongoDbContextEventInbox.cs b/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/MongoDbContextEventInbox.cs index 9d1b706d8b..e5d726526b 100644 --- a/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/MongoDbContextEventInbox.cs +++ b/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/MongoDbContextEventInbox.cs @@ -64,7 +64,7 @@ public class MongoDbContextEventInbox : 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)