Skip to main content
Glama

Database statistics

pg_database_stats
Read-onlyIdempotent

Inspect PostgreSQL database statistics to assess usage patterns and detect deadlocks, temp-file spills, and high rollback ratios.

Instructions

Show pg_stat_database for the current database (or every database with all_databases=true): connections, commits and rollbacks with the rollback ratio, blocks read and hit with the cache hit ratio, rows returned, fetched, inserted, updated and deleted, recovery conflicts, temporary files, deadlocks, I/O times, checksum failures (PostgreSQL 12+), session counts and times (14+) and when the statistics were last reset.

Counters accumulate since the reset. Use it for a first look at how a database is used and to spot deadlocks, temp-file spills and a high rollback ratio.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "pg_database_stats"
  }
}

Input Schema

NameRequiredDescriptionDefault
connectionNo
all_databasesNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.6/5.0
Behavior3/5

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

Annotations already declare readOnlyHint, idempotentHint and destructiveHint=false, so the safety profile is covered. The description adds genuine value beyond that with 'Counters accumulate since the reset' and version-gating notes (checksum failures 12+, session counts 14+), informing that values are cumulative rather than point-in-time. Return shape and pagination are not discussed, though no output schema exists.

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?

Front-loaded with purpose, then the metric inventory, then the accumulation caveat, then usage. The long metric list is dense but each item is a distinguishing signal rather than filler.

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?

With only two optional parameters and no output schema, the enumerated metric list effectively substitutes for a return-value description, which is a strong move. The omission of the 'connection' parameter is the one remaining gap.

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 coverage is 0%, so the description carries the burden. It explains all_databases=true precisely, including the default scope (current database only), but the 'connection' parameter is never mentioned in either schema or description.

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?

Opens with a concrete verb+resource ('Show pg_stat_database for the current database') and enumerates the metrics returned, which makes clear this is database-level counters rather than table/index/column stats. It never names a sibling to contrast with, so it stops short of a 5.

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?

The final sentence gives an explicit use case: a first look at database usage and spotting deadlocks, temp-file spills and high rollback ratio. It offers no when-not guidance and does not route to alternative tools for deeper drill-down.

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