Database Reference
In-Depth Information
@col.insert(doc)
end
end
end
if ARGV.empty? || !(ARGV[0] =~ /^d+$/)
puts "Usage: load.rb [iterations] [name_count]"
else
iterations = ARGV[0].to_i
if ARGV[1] && ARGV[1] =~ /^d+$/
name_count = ARGV[1].to_i
else
name_count = 200
end
write_user_docs(iterations, name_count)
end
If you have the script on hand, you can run it from the command line with no argu-
ments to insert the initial iteration of 200 values:
$ ruby load.rb
Now connect to mongos via the shell. If you query the spreadsheets collection, you'll
see that it contains exactly 200 documents and that they total around 1 MB . You can
also query a document, but be sure to exclude the sample data field (since you don't
want to print 5 KB of text to the screen).
$ mongo arete:40000
> use cloud-docs
> db.spreadsheets.count()
200
> db.spreadsheets.stats().size
1019496
> db.spreadsheets.findOne({}, {data: 0})
{
"_id" : ObjectId("4d6d6b191d41c8547d0024c2"),
"username" : "Cerny",
"updated_at" : ISODate("2011-03-01T21:54:33.813Z"),
"filename" : "sheet-0"
}
Now you can check out what's happened sharding-wise. Switch to the config database
and check the number of chunks:
> use config
> db.chunks.count()
1
There's just one chunk so far. Let's see how it looks:
> db.chunks.findOne()
{
"_id" : "cloud-docs.spreadsheets-username_MinKey_id_MinKey",
"lastmod" : {
Search WWH ::




Custom Search