Documentation

Database Statistics

Database Statistics

View comprehensive statistics about your MongoDB database including storage usage, collection counts, index sizes, and file system metrics. Database statistics help you monitor growth, optimize storage, and plan capacity for your database.

Quick Start

Access database statistics to monitor size, storage, and performance metrics:

  1. Connect to your MongoDB server in VisualLeaf
  2. In the sidebar, right-click on the database you want to analyze
  3. Select Database Statistics from the context menu
  4. The stats view opens with overview cards, storage charts, and detailed metrics
  5. Click Refresh to update statistics at any time
Database Statistics overview showing overview cards, storage usage chart, and detailed stats grid
Video DBST02 Viewing Database Statistics - Navigate to database statistics, explore overview metrics, review storage charts, and refresh data

Overview Cards

The top section displays key metrics in easy-to-read cards that give you an instant snapshot of database health and size:

Metric Description What It Tells You
Collections Total number of collections in the database How many separate data collections exist (excludes views)
Views Total number of views in the database How many virtual collections (aggregation-based views) are defined
Objects Total number of documents across all collections The total count of all BSON documents stored in the database
Data Size Uncompressed size of all documents Actual document data size before compression and padding
Storage Size Compressed size of data on disk How much disk space the data actually consumes (with compression)
Indexes Total number of indexes across all collections How many indexes are defined to optimize query performance
Index Size Total disk space consumed by all indexes How much storage is dedicated to indexes for fast queries
Average Object Size Average size per document Helps predict storage needs and identify bloated documents
Total Size Combined storage + index size Total disk footprint of the entire database

Storage Usage Chart

A visual breakdown shows how storage is distributed across data, indexes, and free space. This helps you understand compression efficiency and storage allocation.

Storage usage chart with pie/donut chart showing data size, index size, and free storage breakdown

Chart Components

  • Data Size - Size of actual document data (typically blue)
  • Index Size - Size of indexes for query optimization (typically purple)
  • Free Storage - Available space within allocated storage (typically gray)
  • Percentage Labels - Shows what portion of total storage each component uses

File System Metrics

Additional file system information provides context about disk capacity:

  • FS Used Size - Total disk space used on the file system where MongoDB stores data
  • FS Total Size - Total capacity of the file system
  • Database % of FS - What percentage of the entire file system this database consumes

Detailed Statistics Grid

The detailed grid displays all raw statistics returned by MongoDB's dbStats command, including advanced metrics:

Detailed statistics grid showing field names and values in a table format
Video DBST05 Understanding Storage Metrics - Explore data size vs storage size, interpret compression ratios, analyze index overhead, and review file system usage

Advanced Metrics

Field Description
freeStorageSize Free storage space available for reuse within allocated files (requires WiredTiger with freeStorage: 1)
indexFreeStorageSize Free storage within index files available for reuse
totalFreeStorageSize Total free storage across data and indexes
scaleFactor Scaling factor for sizes (typically 1 for bytes)
ok Success indicator (1 = success, 0 = error)

Available Actions

Refresh Statistics

Click the Refresh button to reload database statistics. Use this after bulk operations, imports, or index creation to see updated metrics. The refresh executes a new db.stats() command on the server.

Copy Values

Click on individual metric values to copy them to your clipboard for reporting or documentation purposes.

Export Stats

Export the statistics data to JSON or CSV format for external analysis, reporting, or archiving historical metrics.

Pro Tips

  1. Monitor Compression Ratio: Compare Data Size vs Storage Size to see how well MongoDB's compression is working. A good compression ratio means Storage Size is significantly smaller than Data Size.
  2. Watch Index-to-Data Ratio: If Index Size exceeds or approaches Data Size, review your indexes. You may have redundant or unused indexes consuming unnecessary storage.
  3. Track Growth Trends: Refresh statistics periodically and compare Total Size over time to predict when you'll need additional storage capacity.
  4. Free Storage Insights: Large amounts of Free Storage Size indicate deleted documents or shrunk collections. Consider running compact to reclaim disk space (requires maintenance window).
  5. Average Object Size: Use this metric to estimate future storage needs. If you know how many documents you'll add, multiply by average object size for capacity planning.
  6. File System Context: Always check the FS Used/Total metrics. Even if your database is small, other applications or logs might fill the disk.
Video DBST06 Database Statistics Best Practices - Monitor compression efficiency, identify optimization opportunities, track growth trends, and plan capacity

Understanding the Stats Command

VisualLeaf executes the following MongoDB command to retrieve database statistics:

db.stats({ freeStorage: 1 })

The freeStorage: 1 option provides additional free storage metrics available in MongoDB 4.4+. Without this option, you'll only see basic storage totals.

Performance Considerations

  • Light Operation - Database stats is a metadata operation and doesn't scan documents, so it's fast even on large databases
  • Read Lock - Briefly acquires a read lock; minimal impact on running operations
  • Cache Impact - Stats are often served from WiredTiger's metadata cache
  • Safe to Run - You can safely refresh statistics during production workloads
  • Collection Statistics - Drill down into individual collection metrics with 4 detailed tabs (Overview, Indexes, Cache, Storage)
  • All Collections Overview - View statistics for all collections in the database in a single table for easy comparison
  • Server Build Info - Check MongoDB version, modules, SSL configuration, and compression settings
  • Query Monitor - Monitor active operations and identify slow queries affecting performance
  • Profiling Dashboard - Analyze historical query performance and get index recommendations

Ready to try VisuaLeaf?

Download and start managing your MongoDB databases with ease.

Download Free Trial