Skip to content

Instantly share code, notes, and snippets.

View kgorman's full-sized avatar

Kenny Gorman kgorman

View GitHub Profile
{
"_id" : ObjectId("53744abad3a11771ea04bc32"),
"-name" : "Unalaska", // station Name
"-ID" : "9462620", // station ID
"metadata" : {
"location" : {
"lat" : "53.88", // Geo Lat
"long" : "-166.537", // Geo Long
"state" : "AK"
},
{
"_id" : ObjectId("53c281bb2239c277d82494a3"),
"station_id" : 8449130,
"name" : "Nantucket Island",
"lon" : -70.0967,
"products" : [
{
"v" : 72.1,
"t" : ISODate("2014-07-13T12:42:00Z"),
"name" : "water_temperature",
mongoperf < perfsession1.js
mongoperf
use -h for help
options:
{ nThreads: 2, w: true, r: false, mmf: true, fileSizeMB: 256 }
creating test file size:256MB ...
testing...
new thread, total running : 1
9922222 ops/sec
11197085 ops/sec
$>echo "{nThreads:2,w:true,r:false,mmf:false,fileSizeMB:10000}" > perfsession1.js
$>
$>mongoperf < perfsession1.js
$>echo "{nThreads:2,w:true,r:false,mmf:true}" > perfsession1.js
$>
$>mongoperf < perfsession1.js
# Export/Import using named pipe
# Doesn't use disk I/O, just pipes input through pipes
#
# Node 1 | Terminal A
#
mkfifo /tmp/mongodump_pipe
# now export the data
@kgorman
kgorman / gist:5775530
Created June 13, 2013 17:19
balance_check
var balance_check = function(n) {
if ( n ) {
var output = db.chunks.aggregate([
{ $group : { _id : { "_id":"$ns", "shard":"$shard" }, chunks : { $sum : 1 } }},
{ $match : { "_id._id" : n } },
{ $sort : { "chunks" : 1 } }
]);
{
"ts" : ISODate("2012-09-14T16:34:00.010Z"), // date it occurred
"op" : "query", // the operation type
"ns" : "game.players", // the db and collection
"query" : { "total_games" : 1000 }, // query document
"ntoreturn" : 0, // # docs returned with limit()
"ntoskip" : 0, // # of docs to skip()
"nscanned" : 959967, // number of docs scanned
"keyUpdates" : 0, // updates of secondary indexes
"numYield" : 1, // # of times yields took place
MongoM:PRIMARY> db.system.profile.findOne()
{
"ts" : ISODate("2013-02-13T17:23:58.809Z"),
"op" : "insert",
"ns" : "test.foot",
"keyUpdates" : 0,
"numYield" : 0,
"millis" : 0,
"client" : "127.0.0.1",
"user" : ""
@kgorman
kgorman / aggframework1.js
Created February 12, 2013 23:30
Profiler Agg Framework Example1
> db.system.profile.aggregate(
{ $group :
{ _id :"$op",
count:{$sum:1},
"max response time":{$max:"$millis"},
"avg response time":{$avg:"$millis"}
}
});
{