{"uid":"cap_D1hDurazwn2Hc2NlkF6mD","slug":"sql-query-optimizer-for-sqlite-d1-and-turso-fa5450f3","name":"SQL Query Optimizer for SQLite, D1, and Turso","description":"SQL Query Optimizer for D1, SQLite and Turso: Reviews SQL queries, schemas and migrations for SQLite, Cloudflare D1 and Turso, where the bill and the speed follow the rows a query READS, not the rows it returns. Finds full scans hidden behind LIMIT, aggregates over growing tables, index column gaps, NOT IN, OR, functions and LIKE patterns that switch an index off, OFFSET pagination, N+1 loops, the D1 limit of 100 bound parameters, tables that never shrink and new flag columns that turn the whol…","url":"https://api.aiskills402.com/v1/skills/sql-query-optimizer/file?utm_source=zero.xyz","method":"GET","headers":{},"bodySchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["input"],"properties":{"input":{"type":"object","required":["type","method"],"properties":{"type":{"type":"string","const":"http"},"method":{"enum":["GET","HEAD"],"type":"string"},"headers":{"type":"object","additionalProperties":{"type":"string"}}},"additionalProperties":false},"output":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"example":{"type":"object"}}}}},"responseSchema":{"type":"json","example":{"ok":true,"file":{"name":"SKILL.md","content":"<the SKILL.md file>","encoding":"utf-8"},"name":"SQL Query Optimizer for D1, SQLite and Turso","skill":"sql-query-optimizer","sha256":"<sha256 of SKILL.md>","receipt":{"tx":"0x<settlement transaction>","settled":true},"version":"1.0.0","redownload":{"url":"<api>/v1/purchases/<token>","token":"<64 hex chars>"}}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.05","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.05/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.05","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.05","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_eZTDrt-DoyszMaDGSFqe1","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.05","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Reviews SQL queries, schemas, and migrations for SQLite, Cloudflare D1, and Turso databases, identifying performance anti-patterns where cost and speed depend on rows read rather than rows returned.","exampleAgentPrompt":"Can you review this SQL query and schema for my Cloudflare D1 database and tell me if it's doing any full table scans, has index gaps, or uses patterns like NOT IN, OR, or OFFSET that might make it slow or expensive?","exampleUseCases":[{"title":"Audit D1 query hidden full scan","prompt":"I have a Cloudflare D1 query that uses LIMIT 10 but feels slow — can you review it and tell me if it's actually scanning the whole table behind the scenes, and what index or rewrite would fix it?"},{"title":"Check migration for growing-table risk","prompt":"Here's a migration I'm about to run on my Turso database — can you review it for columns or patterns that will cause full scans or unbounded table growth as data scales?"},{"title":"Find N+1 loops in query batch","prompt":"I'm hitting the D1 bound-parameter limit and my queries seem to loop in an N+1 pattern — can you review my SQL and schema and tell me what's causing it and how to fix it?"}],"resultDescription":"A structured analysis identifying performance anti-patterns in the submitted SQL, including full table scans hidden behind LIMIT or aggregates, missing or gapped indexes, problematic operators (NOT IN, OR, LIKE), OFFSET pagination issues, N+1 query loops, D1-specific limits like the 100 bound parameter cap, and schema-level risks like tables that never shrink or flag columns causing full scans — along with specific recommendations to fix each issue.","failureModes":["Missing or malformed SQL input returns an error with no analysis","Extremely large schema files may be truncated","D1-specific advice may not apply if dialect is not specified","Edge cases in complex CTEs or subqueries may be missed","Non-SQLite dialects (PostgreSQL, MySQL) will receive incorrect or inapplicable advice"],"whenToPreferThis":"Choose this endpoint when working specifically with SQLite, Cloudflare D1, or Turso databases where query cost is measured in rows read rather than rows returned — a key distinction from PostgreSQL or MySQL optimizers. Prefer this over generic SQL review tools when you need D1-specific awareness such as the 100 bound parameter limit, or when you suspect full scans hidden behind LIMIT, problematic OFFSET pagination, or index-defeating patterns like NOT IN or functions on indexed columns.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-10T12:34:41.464Z","isFirstParty":false,"canonicalSlug":"sql-query-optimizer-for-sqlite-d1-and-turso-fa5450f3"}