Skip to content

Commit 47e8387

Browse files
committed
mongodb: Add indexes for events
Events are awfully slow even on ordinary request like: https://staging.kernelci.org:9000/latest/events?kind=job&limit=1000&from=2025-12-11T13:00:00 This index should help with that. Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>
1 parent 643ea98 commit 47e8387

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

api/pubsub_mongo.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,11 @@ async def _ensure_indexes(self):
201201
[('channel', ASCENDING), ('sequence_id', ASCENDING)],
202202
name='channel_sequence_id'
203203
)
204+
# Compound index for filtered event queries (kind + timestamp)
205+
await event_col.create_index(
206+
[('data.kind', ASCENDING), ('timestamp', ASCENDING)],
207+
name='kind_timestamp'
208+
)
204209

205210
# Subscriber state indexes
206211
# Unique index on subscriber_id

0 commit comments

Comments
 (0)