Skip to content

Instantly share code, notes, and snippets.

@hperantunes
Created August 23, 2015 20:51
Show Gist options
  • Save hperantunes/2ea06d61906911e6939c to your computer and use it in GitHub Desktop.
Save hperantunes/2ea06d61906911e6939c to your computer and use it in GitHub Desktop.

HOMEWORK: HOMEWORK 3.1

Start a mongod server instance (if you still have a replica set, that would work too).

Next, download the handout and run:

mongo --shell localhost/performance performance.js
homework.init()

Build an index on the "active" and "tstamp" fields. You can verify that you've done your job with

db.sensor_readings.getIndexes()

When you are done, run:

homework.a()

and enter the numeric result below (no spaces).

Note: if you would like to try different indexes, you can use db.sensor_readings.dropIndexes() to drop your old index before creating a new one. (For this problem you will only need one index beyond the _id index which is present by default.)

db.sensor_readings.createIndex({tstamp: 1, active: 1})
homework.a()
6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment