Commit d15e948
Optimize MCP query tools for large databases (#826)
The three heaviest MCP tools (get_top_queries_by_cpu, get_top_procedures_by_cpu,
get_query_store_top) timed out on large databases because they scanned every row,
decompressed text on every row, and returned all results for client-side filtering.
Dashboard: add new MCP-specific service methods using multi-phase temp tables —
aggregate numerics first, rank TOP N, then hydrate text via OUTER APPLY for only
the winners. DECOMPRESS now runs on ~N rows instead of the entire table.
Lite: rewrite queries with CTE-based phasing — inner CTE aggregates numeric-only
columns with LIMIT, outer query hydrates text via LEFT JOIN LATERAL for winners.
Both: push database_name filter and TOP N into SQL instead of client-side filtering.
Shared UI methods are untouched.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent bffd7a7 commit d15e948
5 files changed
Lines changed: 789 additions & 116 deletions
File tree
- Dashboard
- Mcp
- Services
- Lite
- Mcp
- Services
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
| 47 | + | |
54 | 48 | | |
55 | 49 | | |
56 | 50 | | |
| |||
116 | 110 | | |
117 | 111 | | |
118 | 112 | | |
119 | | - | |
| 113 | + | |
120 | 114 | | |
121 | 115 | | |
122 | 116 | | |
123 | 117 | | |
124 | 118 | | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
| 119 | + | |
130 | 120 | | |
131 | 121 | | |
132 | 122 | | |
| |||
187 | 177 | | |
188 | 178 | | |
189 | 179 | | |
190 | | - | |
| 180 | + | |
191 | 181 | | |
192 | 182 | | |
193 | 183 | | |
194 | 184 | | |
195 | 185 | | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
| 186 | + | |
203 | 187 | | |
204 | 188 | | |
205 | 189 | | |
| |||
0 commit comments