Chapter 06 · MongoDB Schema Design
Subchapter 6.20
references/source-slow-query-logs.mdMarkdown2 KBView on GitHub
Retrieves log lines for slow queries as determined by the Performance Advisor. Use to identify slow queries and performance bottlenecks. Provides actual query examples (not shapes) with execution times. Captures all operation types including writes, unlike Query Stats which currently only covers find/aggregate/distinct.
If the API call returns auth or access errors, see the Performance Advisor docs (opens in a new tab).
Atlas Admin API endpoint (query parameters reference (opens in a new tab)):
GET /groups/{PROJECT-ID}/hosts/{HOST-ID}/performanceAdvisor/slowQueryLogsWith MongoDB MCP server:
mcp__plugin_mongodb_mongodb__atlas-get-performance-advisor({
projectId: "507f1f77bcf86cd799439011",
clusterName: "MyCluster",
operations: ["slowQueryLogs"]
})Performance Advisor analyzes up to 200,000 of the cluster’s most recent log lines.
Example response structure:
{
"slowQueries": [
{
"line": "2026-05-06T10:23:45.447+0000 I COMMAND [conn10614] command mydb.orders appName: \"MongoDB Shell\" command: find { find: \"orders\", filter: { status: \"pending\", customerId: 12345 }, sort: { createdAt: -1 } } planSummary: COLLSCAN keysExamined:0 docsExamined:50000 nreturned:100 executionTimeMillis:1247 ...",
"namespace": "mydb.orders"
}
]
}The response contains raw log lines. Parse the log line to extract:
When analyzing slow query logs, focus on:
Slow $lookup operations:
$lookup in the log lineOther slow aggregations: