Skip to content

Commit 8b02e69

Browse files
authored
Add combined index
With multiple queues and thousands of messages, MongoDB is doing a full collection scan. The combined index solves that.
1 parent 7fbbe7c commit 8b02e69

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

Diff for: MongodbContext.php

+1
Original file line numberDiff line numberDiff line change
@@ -161,5 +161,6 @@ public function createCollection(): void
161161
$collection->createIndex(['queue' => 1], ['name' => 'enqueue_queue']);
162162
$collection->createIndex(['priority' => -1, 'published_at' => 1], ['name' => 'enqueue_priority']);
163163
$collection->createIndex(['delayed_until' => 1], ['name' => 'enqueue_delayed']);
164+
$collection->createIndex(['queue' => 1, 'priority' => -1, 'published_at' => 1, 'delayed_until' => 1], ['name' => 'enqueue_combined']);
164165
}
165166
}

0 commit comments

Comments
 (0)