It helps you get a sense of your application's schema, as well as any outliers to that schema. Particularly useful when you inherit a codebase with data dump and want to quickly learn how the data's structured. Also useful for finding rare keys.
This tool helps you get a sense of your application's schema, as well as any outliers to that schema. Particularly useful when you inherit a codebase with data dump and want to quickly learn how the data's structured. Also useful for finding rare keys.
### An Easy Example ###
...
...
@@ -12,7 +12,7 @@ We'll make a collection:
So, let's see what we've got here:
mongo test --eval "var collection = 'users'" keys.js
$ mongo test --eval "var collection = 'users'" keys.js
@@ -30,11 +30,31 @@ Seems like the first document created has a weird legacy key- those damn fools w
Results are stored for future use in a schemaAnalyzerResults database.
### See Progress When Analysis Takes a Long Time ###
Tailing the log is great for this. Mongo provides a "percent complete" measurement for you. These operations can take a long time on huge collections.
### Analyze Only Recent Documents ###
Perhaps you have a really large collection, and you can't wait a whole day for the Schema Analyzer's results.
Perhaps you want to ignore a collection's oldest documents, and only see what the collection's documents' structures have been looking like, as of late.
One can apply a "limit" constraint, which analyzes only the newest documents in a collection, like so: