Skip to content

Commit

Permalink
Try alt index (#1927)
Browse files Browse the repository at this point in the history
* Try alt index

* This is one of the last recommendations that mLabs said to try.
* Also paired with re-investigation mentioned at #1825 (comment)

* Index reordering again

* Seems to be happier. Not quite the ESR rules because isLib has to be first and in those locations or the index never gets used... more likely boolean equality, semi-static preferred equality, semi-static less preferred equality, etc.
* We'll try this for a while.

Ref:
* https://www.mongodb.com/blog/post/performance-best-practices-indexing

Auto-merge
  • Loading branch information
Martii authored Jan 7, 2022
1 parent eed5dc2 commit f1c0811
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions models/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,29 +47,40 @@ var scriptSchema = new Schema({
});

/*
* Manual-indexed
* Manual indexed
*/

scriptSchema.index({
isLib: 1, // A lot of hits
author: 1, // Some hits
name: 1 // Very few hits
// about: 'text' // No hits period when included... only one allowed per Schema
}); // NOTE: Array indexing isn't supported with *mongoose* (yet?)
isLib: 1,
name: 1,
author: 1,
_description: 1,
_about: 1,
'meta.UserScript.include.value': 1
});

scriptSchema.index({
isLib: 1,
name: 1,
author: 1,
_description: 1,
_about: 1,
'meta.UserScript.match.value': 1
});


/*
* Auto-indexed copy
* Direct access indexed
*/

// scriptSchema.index({ // NOTE: This index is currently covered in above manual compound index
// isLib: 1
// });

scriptSchema.index({
installName: 1
});

/*
* Other access indexed
*/

scriptSchema.index({
_authorId: 1,
flagged: 1,
Expand Down

0 comments on commit f1c0811

Please sign in to comment.