Count rows
countGet the exact number of rows in a table, optionally filtered, to size a result before fetching it or answer "how many" questions.
Instructions
Return the exact number of rows in a table, optionally filtered — use it to size a result before fetching it or to answer 'how many' questions. Use query instead for grouped counts (GROUP BY) or counts over joins. Returns a single line: count: N. May be slow on very large unindexed filters (timeout from settings). On failure returns isError with 'error: ' (e.g. refused statement, unknown table, SQL error).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| table | Yes | Table or view name as returned by `tables`. PostgreSQL tables outside `public` are written schema.table. | |
| where | No | Optional SQL boolean expression WITHOUT the WHERE keyword, e.g. status = 'paid' AND total > 100. | |
| database | No | Optional database to use instead of the connection's default (names from `databases`). Omit to use the default. | |
| connection | Yes | Connection name exactly as returned by `connections` (e.g. "shop"). Unknown or unexposed names return an error. |