From f1c0811e308ba8cd0053c2e2122ff3adaaa6e9a7 Mon Sep 17 00:00:00 2001 From: Marti Martz Date: Fri, 7 Jan 2022 06:55:52 -0700 Subject: [PATCH] Try alt index (#1927) * Try alt index * This is one of the last recommendations that mLabs said to try. * Also paired with re-investigation mentioned at https://github.com/OpenUserJS/OpenUserJS.org/issues/1825#issuecomment-1007206823 * 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 --- models/script.js | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/models/script.js b/models/script.js index f5dc4d643..1c2f6816d 100644 --- a/models/script.js +++ b/models/script.js @@ -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,