SQL
Estimate a query's cost
POST
Postgres' plan with its total cost and estimated rows, without running it.
AuthorizationBearer <token>
An API token from POST /v2/tokens (at_live_...), or a project's secret key (sk_...) for server-side ingest.
In: header
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/v2/query/explain" \ -H "Content-Type: application/json" \ -d '{ "sql": "select route, count(*) as views from events where name = \'pageview\' and ts > now() - interval \'7 days\' group by 1 order by 2 desc limit 5" }'{ "data": { "totalCost": 1843.52, "estimatedRows": 5, "plan": [ { "Plan": { "Node Type": "Limit", "Total Cost": 1843.52, "Plan Rows": 5 } } ] }}