Skip to main content
Glama

db_top_queries

Diagnose database performance issues by listing slow or heavy queries from MySQL digest summaries or PostgreSQL pg_stat_statements.

Instructions

Show the slowest / heaviest queries for an instance's DB. MySQL: performance_schema digest summary. Postgres: pg_stat_statements (extension must be enabled). For the shared-RDS noisy-neighbour case. Requires a db_profile; password from your secret store. Read-only query.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
appNoWebsite/app to target when the instance hosts several DBs; matched loosely against stored site labels. Omit for a single DB.
limitNoHow many queries to return (1–100, default 15).
instance_idYesInstance ID or name. '<account>/<name>' picks the server of one provider account; custom servers are 'custom/<name>'.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv2.28.0
    • changedInput schema / properties / instance_id / description
      Previous value: -"Instance ID, name, or custom-server name."New value: +"Instance ID or name. '<account>/<name>' picks the server of one provider account; custom servers are 'custom/<name>'."
  2. Addedv2.24.0
  3. Removedv2.23.8
  4. Changed1 schema field changedv2.23.0
    • addedInput schema / properties / app
      Added value: +{
      +  "default": "",
      +  "description": "Website/app to target when the instance hosts several DBs; matched loosely against stored site labels. Omit for a single DB.",
      +  "type": "string"
      +}
  5. First observedv1.0.0

TDQS

A3.9/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and does well: it declares the operation read-only, discloses the engine-specific instrumentation used, and flags the Postgres extension prerequisite plus the db_profile/secret-store auth requirement. It omits any statement about return size, cost, or whether the profiling itself is heavy on a production instance.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Short and front-loaded, with the core purpose in the first clause and prerequisites after. The telegraphic fragments ('For the shared-RDS noisy-neighbour case.') are efficient but slightly cryptic in isolation.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema or annotations exist, so the description must set expectations, and it does cover the data source, read-only nature, and setup requirements. It leaves the returned shape and the interaction between db_profile and instance_id unaddressed, but nothing critical to correct invocation is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% and all three parameters are documented there, so the baseline is 3. The description adds a genuine extra: it reveals a required 'db_profile' concept that is not in the schema at all, which is useful context but also leaves the relationship between db_profile and instance_id unexplained.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Show the slowest / heaviest queries for an instance's DB') and even names the underlying per-engine data sources, which tells an agent exactly what it will get. It does not, however, contrast itself against the close sibling db_processlist, so an agent must infer the difference between 'top queries by resource' and 'currently running queries'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives a concrete usage context ('For the shared-RDS noisy-neighbour case') and prerequisites ('Requires a db_profile; password from your secret store', pg_stat_statements must be enabled). It stops short of naming an explicit alternative tool for the single-DB case, which keeps it out of 5 territory.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.