Skip to main content
Glama

Count Rows

db_count
Read-onlyIdempotent

Get exact row counts for any table with optional filters. Use precise COUNT(*) results for reporting, validation, or confirming scope before bulk operations.

Instructions

Returns the exact number of rows in a table, optionally filtered. This runs an exact COUNT(*) query — not an estimate. Use this when you need a precise count for reporting, validation, or before performing bulk operations.

When to use:

  • "How many users signed up this week?"

  • "Count all orders with status pending"

  • Before bulk deletes, to confirm the scope of the operation

Parameter guidance:

  • table: the table name (required)

  • where: optional JSON filter object (same syntax as db_find_many)

Behavioral notes:

  • Exact COUNT(*) on large tables (millions of rows) may be slow.

  • On large tables, consider using db_aggregate with a group-by for approximate breakdowns.

  • Returns an integer count, not a row object.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tableYesName of the table to query
whereNoOptional JSON filter object
databaseNoName of the database to query (from pgautopilot.json). Omit to use the current default database.
Install Server

TDQS

A4.9/5.0
Behavior5/5

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

Beyond the annotations, the description discloses that the tool runs exact COUNT(*) queries, may be slow on millions of rows, and returns an integer rather than a row object. This adds meaningful behavioral context that annotations alone do not provide.

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

Conciseness5/5

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

The description is well-organized with clear sections, front-loaded core behavior, and no redundancy. Every sentence contributes guidance: exactness, use cases, parameter guidance, and performance caveats.

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

Completeness5/5

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

Given three parameters, no output schema, and the need to differentiate from many sibling tools, this description is complete. It covers return type, performance trade-offs, filtering syntax, helpful examples, and when to choose an alternative.

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

Parameters4/5

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

Schema coverage is 100%, providing a baseline of 3, but the description adds value by clarifying table is required, explaining the where parameter uses the same syntax as db_find_many, and noting the result type. This goes beyond the basic schema descriptions.

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

Purpose5/5

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

The description states a specific verb and resource: 'Returns the exact number of rows in a table, optionally filtered.' It explicitly contrasts with an estimate ('exact COUNT(*) query — not an estimate') and helps distinguish itself from siblings like db_aggregate and db_find_many.

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

Usage Guidelines5/5

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

The description gives concrete when-to-use examples ('How many users signed up this week?', 'Count all orders with status pending') and explicitly recommends an alternative tool for large tables ('consider using db_aggregate'). It also references db_find_many's syntax, giving clear routing among siblings.

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

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cyberreinxy/pgautopilot'

If you have feedback or need assistance with the MCP directory API, please join our Discord server