Skip to content

Commit 819f84e

Browse files
committed
Add index creation step to CI for aggregation performance
Create index on comments.movie_id after data restore to fix the /reportingByComments aggregation timeout. Without this index, the $lookup operation performs a full collection scan (41K comments x 21K movies) causing 5+ minute response times in CI vs ~700ms locally.
1 parent 56a2f3c commit 819f84e

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

.github/workflows/run-express-tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ jobs:
4141
- name: Add sample data to database
4242
run: mongorestore --archive=sampledata.archive --port=27017
4343

44+
- name: Create indexes for aggregation performance
45+
run: |
46+
mongosh "mongodb://localhost:27017/sample_mflix?directConnection=true" --eval "db.comments.createIndex({ movie_id: 1 })"
47+
4448
- name: Set up Node.js
4549
uses: actions/setup-node@v4
4650
with:

0 commit comments

Comments
 (0)