perf: cut MongoDB scans in repository workflows (#780)

* Add repository name index

* Optimize repository file counts

* Optimize MongoDB query workloads
This commit is contained in:
Thomas Durieux
2026-08-20 12:29:26 +02:00
committed by GitHub
parent a30457993d
commit 7aa9557905
12 changed files with 124 additions and 61 deletions
@@ -14,7 +14,7 @@ const AnonymizedGistSchema = new Schema({
anonymizeDate: Date,
lastView: Date,
pageView: Number,
owner: Schema.Types.ObjectId,
owner: { type: Schema.Types.ObjectId, index: true },
conference: String,
source: {
gistId: String,
@@ -14,7 +14,7 @@ const AnonymizedPullRequestSchema = new Schema({
anonymizeDate: Date,
lastView: Date,
pageView: Number,
owner: Schema.Types.ObjectId,
owner: { type: Schema.Types.ObjectId, index: true },
conference: String,
source: {
pullRequestId: Number,
@@ -77,4 +77,15 @@ const AnonymizedRepositorySchema = new Schema({
},
});
AnonymizedRepositorySchema.index({ "source.repositoryName": 1 });
AnonymizedRepositorySchema.index({ status: 1, statusDate: 1 });
AnonymizedRepositorySchema.index({ lastView: 1 });
AnonymizedRepositorySchema.index({ anonymizeDate: 1 });
AnonymizedRepositorySchema.index({ status: 1, isReseted: 1, lastView: 1 });
AnonymizedRepositorySchema.index({
status: 1,
isReseted: 1,
"options.expirationDate": 1,
});
export default AnonymizedRepositorySchema;
@@ -55,4 +55,7 @@ const RepositorySchema = new Schema({
},
});
RepositorySchema.index({ owners: 1 });
RepositorySchema.index({ status: 1, endDate: 1 });
export default RepositorySchema;
+8
View File
@@ -13,6 +13,14 @@ const FileSchema = new Schema({
});
FileSchema.index({ path: 1, repoId: 1 });
FileSchema.index(
{ repoId: 1, size: 1, path: 1 },
{ name: "repoId_1_size_1_path_1" }
);
FileSchema.index(
{ repoId: 1, path: 1, name: 1 },
{ name: "repoId_1_path_1_name_1" }
);
FileSchema.methods.toString = function () {
return `${this.path}/${this.name}`;
+2
View File
@@ -58,4 +58,6 @@ const UserSchema = new Schema({
},
});
UserSchema.index({ dateOfEntry: 1 });
export default UserSchema;