Inspect mongoDB queries to find queries not using an index.
mongoQueryInspector is written in Node.
Please note: mongoQueryInspector is NOT intended for usage on a production system!
mongoQueryInspector uses system.profile collections to analyze mongo queries. In order to analyze all queries for a specific database, follow these steps:
-
Enable database profiling for the database(s) you want to analyze. You need to set the profiling level to 2 (db.setProfilingLevel(2)).
-
Open fire! Start using your application/run your queries.
-
Edit the config.json file and change it according to your MongoDB setup.
-
Start mongo query inspector and analyze the results
- clone the repository
- use npm install:
npm install
For logging and database configuration edit the config.json file:
"log": {
"path": "c:\\temp" - The path where the log file will be created. Use '\\' when specifying the path.
"fileName": "mongoQueryInspector.log" - The name of the log file to be created.
"useTeamCityLog": true - [true]=logging to console in Team City format. No logs will be written to the log file; [false]=normal logging to console.
},
"databases": [
"mongodb://user:passwd@host:port/database"
]
You can specify as many databases as you like. Each DB in the databases array will be analyzed by mongo query inspector.
Start app.js with node
$node app.js
Start app.js with mongo connection string parameter
$node app.js --uri mongodb://user:passwd@host:port/database
If a query is detected that is not using an index, a log entry is written to console and to the log file you specified in the configuration.