R2 SQL
R2 SQLOpen Beta
Cloudflare

Serverless Query Engine

Query petabytes of data in R2 Data Catalog directly — no infrastructure to manage, no clusters to provision.

Distributed Execution

Queries run across Cloudflare's global network

Intelligent File Pruning

Uses Iceberg metadata to skip irrelevant data files

Edge-Native

Process data where it lives, not in centralized clusters

Free in Beta, Pay Per Query at GA

Only pay for the data you actually scan

190+ functions, expressions, and complex types
CTEsCASEGROUP BYHAVING163 Scalar Fns33 AggregatesStats/RegressionStructsArraysMapsEXPLAIN
Terminal
$ npx wrangler r2 sql query "my-warehouse"
1WITH stats AS (
2 SELECT
3 category,
4 COUNT(*) AS total,
5 ROUND(AVG(amount), 2) AS avg_amt,
6 APPROX_PERCENTILE_CONT(amount, 0.95) AS p95
7 FROM default.orders
8 WHERE __ingest_ts >= '2026-01-01'
9 GROUP BY category
10)
11SELECT *, CASE
12 WHEN avg_amt > 100 THEN 'premium'
13 ELSE 'standard'
14END AS tier
15FROM stats ORDER BY total DESC LIMIT 10;
Query Result (3 rows, 0.38s)
categorytotalavg_amtp95tier
Electronics245,832149.90499.00premium
Books192,45124.5059.99standard
Home156,23487.30299.00standard
7 / 12