Count Rows in Table
pg_count_rowsGet the exact row count for a PostgreSQL table, with optional WHERE filter. Provides precise count for tables of any size.
Instructions
Get exact row count for a table, optionally with a filter condition.
Args:
table: Table name (required)
schema: Schema name (default: public)
where_clause: Optional WHERE condition (without the WHERE keyword)
Returns: JSON: { table, schema, count, where_clause } Markdown: formatted count with filter info
Note: For large tables (>10M rows), pg_table_stats provides a faster estimated count.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"table": "<table>"
},
"name": "pg_count_rows"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| table | Yes | Table name | |
| schema | No | PostgreSQL schema name (default: public) | public |
| where_clause | No | Optional WHERE condition without 'WHERE', e.g. "status = 'active'" |