Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
e4aaf497
Commit
e4aaf497
authored
Aug 25, 2014
by
Don Mitchell
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4899 from edx/dhm/mongo_indices
Refactored expected indices after email w/ mongo
parents
b3f4ce23
ceae081c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
54 deletions
+9
-54
mongo_indexes.md
+9
-54
No files found.
mongo_indexes.md
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment