Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
e4aaf497
Commit
e4aaf497
authored
10 years ago
by
Don Mitchell
Browse files
Options
Downloads
Plain Diff
Merge pull request #4899 from edx/dhm/mongo_indices
Refactored expected indices after email w/ mongo
parents
b3f4ce23
ceae081c
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mongo_indexes.md
+9
-53
9 additions, 53 deletions
mongo_indexes.md
with
9 additions
and
53 deletions
mongo_indexes.md
+
9
−
53
View file @
e4aaf497
...
...
@@ -20,16 +20,14 @@ which can be `uploadDate`, `display_name`,
Replace existing index which leaves out
`run`
with this one:
```
ensureIndex({'_id.tag': 1, '_id.org': 1, '_id.course': 1, '_id.category': 1, '_id.run': 1})
ensureIndex({'content_son.tag': 1, 'content_son.org': 1, 'content_son.course': 1, 'content_son.category': 1, 'content_son.run': 1})
ensureIndex({'_id.org': 1, '_id.course': 1, '_id.name': 1}, {'sparse': true})
ensureIndex({'content_son.org': 1, 'content_son.course': 1, 'content_son.name': 1}, {'sparse': true})
ensureIndex({'_id.org': 1, '_id.course': 1, 'uploadDate': 1}, {'sparse': true})
ensureIndex({'_id.org': 1, '_id.course': 1, 'display_name': 1}, {'sparse': true})
ensureIndex({'content_son.org': 1, 'content_son.course': 1, 'uploadDate': 1}, {'sparse': true})
ensureIndex({'content_son.org': 1, 'content_son.course': 1, 'display_name': 1}, {'sparse': true})
```
Note: I'm not advocating adding one which leaves out
`category`
for now because that would only be
used for
`delete_all_course_assets`
which in the future should not actually delete the assets except
when doing garbage collection.
Remove index on
`displayname`
modulestore:
============
...
...
@@ -41,7 +39,7 @@ and no field is omitted.
Because we often query for some subset of the id, we define this index:
```
ensureIndex({
'_id.tag': 1,
'_id.org': 1, '_id.course': 1, '_id.category': 1, '_id.name':
1, '_id.revision':
1})
ensureIndex({'_id.org': 1, '_id.course': 1, '_id.category': 1, '_id.name': 1})
```
Because we often scan for all category='course' regardless of the value of the other fields:
...
...
@@ -51,54 +49,12 @@ ensureIndex({'_id.category': 1})
Because lms calls get_parent_locations frequently (for path generation):
```
ensureIndex({'_id.tag': 1, '_id.org': 1, '_id.course': 1, 'definition.children': 1})
```
Remove these indices if they exist as I can find no use for them:
```
{ "_id.course": 1, "_id.org": 1, "_id.revision": 1, "definition.children": 1 }
{ "definition.children": 1 }
```
NOTE, that index will only aid queries which provide the keys in exactly that form and order. The query can
omit later fields of the query but not earlier. Thus
```modulestore.find({'_id.org': 'myu'})```
will not use
the index as it omits the tag. As soon as mongo comes across an index field omitted from the query, it stops
considering the index. On the other hand,
```modulestore.find({'_id.tag': 'i4x', '_id.org': 'myu', '_id.category': 'problem'})```
will use the index to get the records matching the tag and org and then will scan all of them
for matches to the category.
To find out if any records have the wrong id structure, run
```
db.fs.files.find({uploadDate: {$gt: startDate, $lt: endDate},
$where: function() {
var keys = ['category', 'name', 'course', 'tag', 'org', 'revision'];
for (var key in this._id) {
if (key != keys.shift()) {
return true;
}
}
return false;
}},
{_id: 1})
ensureIndex({'definition.children': 1}, {'sparse': true})
```
modulestore.active_versions
===========================
```
ensureIndex({'org': 1, 'offering': 1})
```
modulestore.structures
======================
```
ensureIndex({'previous_version': 1})
```
modulestore.definitions
=======================
ensureIndex({'org': 1, 'course': 1, 'run': 1}, {'unique': true})
```
ensureIndex({'category': 1})
```
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment