Skip to content

Commit

Permalink
Merge pull request #409 from BibliothecaDAO/add-mongo-indexes
Browse files Browse the repository at this point in the history
adds indexes to mongodb to improve performance
  • Loading branch information
starknetdev authored Oct 14, 2023
2 parents d99116c + 683e980 commit b686fe0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions indexer/goerli-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ services:
- "27017:27017"
volumes:
- mongo_data:/data/db
- ./scripts/mongo-init:/docker-entrypoint-initdb.d
environment:
MONGO_INITDB_ROOT_USERNAME: mongo
MONGO_INITDB_ROOT_PASSWORD: mongo
Expand Down
38 changes: 38 additions & 0 deletions indexer/scripts/mongo-init/init-mongo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
db = db.getSiblingDB('mongo_goerli');

//
// add indexes
//
// items
db.items.createIndex({ "_cursor.to": 1, "adventurerId": 1, "item": 1});
db.items.createIndex({ "adventurerId": 1, "item": 1});
db.items.createIndex({ "_cursor.from": 1 });
db.items.createIndex({ "_cursor.to": 1 });

// adventurers
db.adventurers.createIndex({ "_cursor.to": 1, "adventurerId": 1 });
db.adventurers.createIndex({ "_cursor.from": 1 });
db.adventurers.createIndex({ "_cursor.to": 1 });
db.adventurers.createIndex({ "xp": -1 });

// battles
db.battles.createIndex({ "_cursor.to": 1, "adventurerId": 1 });
db.battles.createIndex({ "_cursor.from": 1 });
db.battles.createIndex({ "_cursor.to": 1 });

// beasts
db.beasts.createIndex({ "_cursor.to": 1, "adventurerId": 1 });
db.beasts.createIndex({ "_cursor.from": 1 });
db.beasts.createIndex({ "_cursor.to": 1 });

// discoveries
db.discoveries.createIndex({ "_cursor.to": 1, "adventurerId": 1 });
db.discoveries.createIndex({ "_cursor.from": 1 });
db.discoveries.createIndex({ "_cursor.to": 1 });

// scores
db.scores.createIndex({ "_cursor.to": 1, "adventurerId": 1 });
db.scores.createIndex({ "_cursor.from": 1 });
db.scores.createIndex({ "_cursor.to": 1 });
db.scores.createIndex({ "xp": -1});
db.scores.createIndex({ "rank": -1});

1 comment on commit b686fe0

@vercel
Copy link

@vercel vercel bot commented on b686fe0 Oct 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.