Skip to content

Commit 3e73b21

Browse files
committed
Limit max num of slow queries returned by the tool
1 parent 35b695d commit 3e73b21

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/common/atlas/performanceAdvisorUtils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ export type DropIndexSuggestion = components["schemas"]["DropIndexSuggestionsInd
88
export type SlowQueryLogMetrics = components["schemas"]["PerformanceAdvisorSlowQueryMetrics"];
99
export type SlowQueryLog = components["schemas"]["PerformanceAdvisorSlowQuery"];
1010

11+
export const DEFAULT_SLOW_QUERY_LOGS_LIMIT = 100;
12+
1113
interface SuggestedIndexesResponse {
1214
content: components["schemas"]["PerformanceAdvisorResponse"];
1315
}
@@ -128,6 +130,7 @@ export async function getSlowQueries(
128130
query: {
129131
...(since && { since: since.getTime() }),
130132
...(namespaces && { namespaces: namespaces }),
133+
nLogs: DEFAULT_SLOW_QUERY_LOGS_LIMIT,
131134
},
132135
},
133136
})

src/tools/atlas/read/getPerformanceAdvisor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
getDropIndexSuggestions,
99
getSchemaAdvice,
1010
getSlowQueries,
11+
DEFAULT_SLOW_QUERY_LOGS_LIMIT,
1112
} from "../../../common/atlas/performanceAdvisorUtils.js";
1213
import { AtlasArgs } from "../../args.js";
1314

@@ -20,8 +21,7 @@ const PerformanceAdvisorOperationType = z.enum([
2021

2122
export class GetPerformanceAdvisorTool extends AtlasToolBase {
2223
public name = "atlas-get-performance-advisor";
23-
protected description =
24-
"Get MongoDB Atlas performance advisor recommendations, which includes the operations: suggested indexes, drop index suggestions, slow query logs, and schema suggestions";
24+
protected description = `Get MongoDB Atlas performance advisor recommendations, which includes the operations: suggested indexes, drop index suggestions, schema suggestions, and a sample of the most recent (max ${DEFAULT_SLOW_QUERY_LOGS_LIMIT}) slow query logs`;
2525
public operationType: OperationType = "read";
2626
protected argsShape = {
2727
projectId: AtlasArgs.projectId().describe("Atlas project ID to get performance advisor recommendations"),

0 commit comments

Comments
 (0)