Skip to main content
POST
Count Query Results

Overview

Companion endpoint to Execute: instead of returning records, it returns how many rows the query produces. The count respects the query’s LIMIT, and execution stops as soon as the limit is reached - which makes capped counting on very large objects fast. Use it for:
  • Tile counts - SELECT DISTINCT id ... LIMIT 100001 returns in a fraction of the time of a full COUNT(DISTINCT id) aggregate when the cap is reached. If the result equals the limit, display it as “1,00,000+”; if it is below the limit, it is already the exact count.
  • Existence / threshold checks - “are there at least N matching records?” without scanning everything.
The request body, authentication, and query rules are identical to Execute, including the relationship guidance (use DISTINCT id whenever a virtual relation appears in the query, since the join can return one row per child).

Request Body

string
required
Raw PostgreSQL SELECT query. Include a LIMIT - it caps both the scan and the returned count.
string
required
Base CRM object slug matching the query’s top-level FROM.

Example Request

Example Response

Here the count equals the limit, so the true total is at least 100,001 - render it as a capped value (“1,00,000+”) or follow up with an exact aggregate if needed.