# SQL Query Optimizer for SQLite, D1, and Turso

> SQL Query Optimizer for SQLite, D1, and Turso is a paid API for AI agents from api.aiskills402.com, paid per call via x402, $0.05/call, status unknown (last checked 2026-10-10).

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.

## Facts

- Endpoint: GET https://api.aiskills402.com/v1/skills/sql-query-optimizer/file?utm_source=zero.xyz
- Price: $0.05/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-10
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/sql-query-optimizer-for-sqlite-d1-and-turso-fa5450f3
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_D1hDurazwn2Hc2NlkF6mD

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability sql-query-optimizer-for-sqlite-d1-and-turso-fa5450f3
```

Example prompt: 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?

## When to prefer this

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.

## Known failure modes

- 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

## How this service works

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…

## Output

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.

## Request schema (JSON Schema)

```json
{
 "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"
    }
   }
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "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>"
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/sql-query-optimizer-for-sqlite-d1-and-turso-fa5450f3/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from api.aiskills402.com](https://www.zero.xyz/host/api.aiskills402.com/llms.txt)
