Over a million developers have joined DZone.

10 Largest Collections in a MongoDB Database w/ Mongoid

DZone's Guide to

10 Largest Collections in a MongoDB Database w/ Mongoid

· Big Data Zone ·
Free Resource

Hortonworks Sandbox for HDP and HDF is your chance to get started on learning, developing, testing and trying out new features. Each download comes preconfigured with interactive tutorials, sample data and developments from the Apache community.

Mongoid.default_session.collections.map do |c|
  s = Mongoid.default_session.command(collstats: c.name)
  [ c.name, s["size"] + s["totalIndexSize"] ]
end.sort_by { |n, s| -s }.take(10).each do |n, s|
  puts "#{n}: #{s}"
end; nil

outputs something like this...

squirrels: 5432044544
monkeys: 949976816
sleuths: 723951712

Hortonworks Community Connection (HCC) is an online collaboration destination for developers, DevOps, customers and partners to get answers to questions, collaborate on technical articles and share code examples from GitHub.  Join the discussion.


Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}