Documentation

Query Profiler & Performance Analyzer

Query Profiler & Performance Analyzer

Analyze MongoDB query performance, identify slow queries, view execution plans, and get optimization recommendations. The Query Profiler helps you understand how your queries execute and where to improve performance.

Quick Start

Start profiling your queries in seconds:

  1. Open the Query Profiler from the sidebar or menu
  2. Select a database and collection to profile
  3. View real-time query metrics and slow query logs
  4. Click on any query to see its execution plan
  5. Review index usage and optimization suggestions
Query Profiler main interface showing query list, metrics, and execution timeline

Profiler Dashboard

The profiler dashboard gives you a real-time view of query performance across your MongoDB database.

Key Metrics

Metric Description
Execution Time Total time in milliseconds for the query to complete
Documents Scanned Number of documents MongoDB examined to fulfill the query
Documents Returned Number of documents returned to the client
Index Keys Examined Number of index entries scanned
Scan Efficiency Ratio of documents returned to documents scanned (higher is better)

Slow Query Log

The slow query log captures queries that exceed a configurable threshold, helping you identify performance bottlenecks.

Slow query log showing list of queries with execution times and collection names

Slow Query Features

  • Threshold Configuration: Set custom thresholds (e.g., queries over 100ms)
  • Query Grouping: Group similar queries by shape to identify patterns
  • Time Range Filter: Filter queries by time range (last hour, day, week)
  • Collection Filter: Focus on specific collections
  • Export Logs: Export slow query data for analysis

Execution Plans

View detailed execution plans (explain output) for any query to understand how MongoDB processes it.

Execution plan showing query stages, index usage, and performance statistics

Explain Modes

Mode Description
queryPlanner Shows the query plan without executing it
executionStats Executes the query and shows actual statistics
allPlansExecution Shows statistics for all considered plans

Understanding Plans

  • COLLSCAN: Full collection scan (no index used) - usually indicates a missing index
  • IXSCAN: Index scan - efficient query using an index
  • FETCH: Document retrieval after index scan
  • SORT: In-memory sort operation (can be slow for large datasets)
  • PROJECTION: Field projection stage

Index Recommendations

Get AI-powered index recommendations based on your query patterns and execution statistics.

Index recommendations panel showing suggested indexes with impact estimates

Recommendation Types

  • Missing Index: Queries that would benefit from a new index
  • Compound Index: Suggestions to combine multiple fields into one index
  • Covered Query: Indexes that could make queries fully covered (no FETCH needed)
  • Unused Index: Indexes that are not being utilized and could be removed

Query Timeline

Visualize query performance over time with interactive charts and graphs.

Query timeline showing scatter plot of query execution times over time

Timeline Features

  • Scatter Plot: Each dot represents a query, positioned by time and duration
  • Color Coding: Different colors for different collections or query types
  • Zoom & Pan: Interactive zoom to focus on specific time ranges
  • Click to Inspect: Click any data point to view query details
  • Percentile Lines: P50, P95, P99 lines to understand distribution

Live Monitoring

Monitor queries in real-time as they execute on your MongoDB server.

Live monitoring panel showing current running operations with ability to kill queries

Live Monitoring Features

  • Current Operations: See all currently running queries
  • Kill Query: Terminate long-running or problematic queries
  • Auto-Refresh: Configurable refresh interval
  • Filter by Type: Filter by operation type (find, aggregate, update, etc.)
  • Connection Info: See which client/connection issued each query

Profiler Settings

Configure profiling behavior and thresholds.

Setting Description Default
Slow Query Threshold Minimum execution time to log as slow (milliseconds) 100ms
Profiling Level 0 = off, 1 = slow queries only, 2 = all queries 1
Sample Rate Percentage of queries to sample (for high-traffic databases) 100%
Max Log Size Maximum number of queries to keep in memory 10,000

Pro Tips

  1. Start with Slow Queries: Focus on the slowest queries first for maximum impact.
  2. Check Scan Efficiency: If documents scanned >> documents returned, you likely need an index.
  3. Monitor After Changes: After adding indexes, monitor to verify improvement.
  4. Use Compound Indexes: One well-designed compound index is often better than multiple single-field indexes.
  5. Consider Covered Queries: Design indexes that include all fields you need to avoid FETCH stages.

Ready to try VisuaLeaf?

Download and start managing your MongoDB databases with ease.

Download Free Trial