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

The open source HPCC Systems platform is a proven, easy to use solution for managing data at scale. Visit our Easy Guide to learn more about this completely free platform, test drive some code in the online Playground, and get started today.

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

Managing data at scale doesn’t have to be hard. Find out how the completely free, open source HPCC Systems platform makes it easier to update, easier to program, easier to integrate data, and easier to manage clusters. Download and get started today.


Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}