LAB QUOTA · OK
[ sql-nl:// ] experimental
cat: code model: @cf/meta/llama-3.1-8b-instruct

Type what you want to fetch in plain English + paste your schema. Get the SQL, the dialect of your choice (Postgres / MySQL / SQLite / Snowflake), and a quick EXPLAIN-style read of how the planner will run it.

// system prompt
User provides: (1) a natural-language question, (2) an optional table schema. Output:
1. SQL in the requested dialect (default Postgres)
2. ONE-LINE explanation of what it returns
3. EXPLAIN read — which join order, index usage, complexity class
4. ONE OPTIMISATION HINT if applicable

Use CTEs over subqueries when nesting > 1 level. Quote identifiers only when reserved. No leading semicolons.
⚡ powered by Cloudflare Workers AI · quota deducted on success
// sample output
SELECT u.id, u.signup_date, SUM(o.total) AS total_spend
FROM users u
JOIN orders o ON o.user_id = u.id
WHERE u.plan = 'pro'
  AND u.signup_date > now() - interval '90 days'
GROUP BY u.id, u.signup_date
ORDER BY total_spend DESC
LIMIT 10;

EXPLAIN: Index scan on users(plan, signup_date) then nested loop into orders(user_id). O(n log n).
HINT: Add a covering index on users(plan, signup_date) if not already there.
// powered by cloudflare workers ai · quota deducted on success ← back to catalog