alexbevi/mongo_explain: A Ruby/Rails tool to emit and disply explain plans for MongoDB database operations
MongoExplain is a development-only Ruby/Rails gem that monitors MongoDB operations and surfaces explain plans to help developers identify expensive or unindexed queries. It hooks into the MongoDB Ruby driver's command event monitoring to capture query shapes and generate explain plans with executionStats verbosity. Two usage modes are available: a Rails Engine integration that renders a live ActionCable overlay in the browser showing query plan cards, and a standalone console mode that emits structured log lines. Key logged fields include callsite (the exact Ruby file/line that triggered the query), operation, namespace, plan stage path, index names, and execution stats. Optional filtering via MONGO_EXPLAIN_ONLY_COLLSCAN limits output to collection scans only.