gotchas.md

Created about 12 hours ago

attributes
source_pathreferences/sql/gotchas.md
source_sha25695f5732f84c1a3c76c5463bb52a793cd27350793050dd1946fff11dab63a64a9
source_urlhttps://github.com/cloudflare/skills/blob/47dfc2ce969bf62acf8bc231198ade4bb02712e0/skills/basin/references/sql/gotchas.md
supporting_skill_id40178
upstream_revision47dfc2ce969bf62acf8bc231198ade4bb02712e0

Basin SQL Gotchas

Operational pitfalls. For the authoritative list of supported features, unsupported features, and recommended workarounds, pull https://developers.cloudflare.com/basin-sql/reference/limitations-best-practices/index.md and https://developers.cloudflare.com/basin-sql/troubleshooting/index.md.

Access

  • No Workers binding. There is no env.R2_SQL. Query the REST endpoint via fetch() from a Worker (patterns.md), or use D1 / an external DB for OLTP.
  • Wrangler needs WRANGLER_BASIN_SQL_AUTH_TOKEN — it does not reuse the wrangler login OAuth session.
  • R2 Storage Admin Read & Write is currently required even for read-only queries. Verify this in the live authentication docs.

Type Safety

-- ❌ wrong                          -- ✅ right
WHERE status = '200'                 WHERE status = 200
WHERE ts > '2026-01-01'              WHERE ts > '2026-01-01T00:00:00Z'   -- need time + tz
WHERE method = GET                   WHERE method = 'GET'

No implicit conversions. Timestamps must be RFC3339 with timezone; dates ISO 8601.

Performance

  • File count dominates latency — enable automatic compaction.
  • Partition-filter + narrow time windows + always LIMIT.
  • Multi-way JOINs on large tables can exceed resource limits — filter heavily, join through dimension tables.
  • Per-query metrics (files_scanned, bytes_scanned, cache_hits) are the primary observability signal; bytes_scanned ≈ billable data. For LIMIT bounds, pagination, and other guidance, see the limitations-best-practices doc.

Debug Checklist

  1. wrangler basin catalog enable <bucket> — catalog on?
  2. echo $WRANGLER_BASIN_SQL_AUTH_TOKEN — token set?
  3. SHOW DATABASES → SHOW TABLES IN ns → DESCRIBE ns.table
  4. SELECT COUNT(*) FROM ns.table — data present?
  5. Add filters incrementally; read metrics to tune.

See Also

Children

No children yet.

Like how this is organised?

Build your own Memory tree on knowen.md: notes, decisions and tasks in one connected markdown graph, shared with your team and your AI agents.