Count rows
pg_count_rowsCount rows in a PostgreSQL table: get an instant planner-statistics estimate, or the exact count(*) by setting exact=true. Use the estimate on big tables to avoid a full scan.
Instructions
Count the rows of a table: an instant estimate from the planner statistics, and with
exact=true the real count(*).
The estimate costs nothing and is usually within a few percent; it adds up the partitions or child tables of a partitioned table, and says when the table was last analyzed (a table never analyzed has no useful estimate). The exact count reads the whole table, so on a big table prefer the estimate, or filter with pg_query.
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 |
|---|---|---|---|
| exact | No | ||
| table | Yes | ||
| connection | No |