Interactive Demo — Runs in Browser

QueryMind

Paste any SQL query. Instantly get a performance score, a list of anti-patterns with explanations, and an optimized rewrite — no server, no signup.

SQL Analysis Engine 10 Detection Rules Auto Optimizer Python Backend + CLI
Try it live ↓
Interactive Demo

Analyze a SQL query right now

Try a sample query
🖊 SQL Editor
PostgreSQL dialect
1
Ctrl + ↵
🔍

Write or paste a SQL query on the left,
then click Analyze to see results.

Analyzing query…
Detection Rules

What QueryMind catches

Backend Code

The Python engine behind the demo

The demo above runs the analysis engine ported to JavaScript. The original is a Python package with a command-line tool. Same rules, same scoring: the JS version mirrors it exactly.

src/analyzer.py (Python backend)
@dataclass
class AnalysisReport:
    query:  str
    issues: List[Issue] = field(default_factory=list)
    score:  int = 100

    PENALTIES = {"HIGH": 25, "MEDIUM": 10, "LOW": 5}

    @property
    def grade(self) -> str:
        if self.score >= 90: return "A"
        if self.score >= 75: return "B"
        if self.score >= 60: return "C"
        if self.score >= 40: return "D"
        return "F"

class SQLAnalyzer:
    def _rule_leading_wildcard(self, norm, raw):
        if re.search(r"LIKE\s+'%\w", norm):
            return Issue(
                severity="HIGH", code="LEADING_WILDCARD",
                description="LIKE '%...' disables B-tree index, forces full table scan.",
                suggestion="Use GIN full-text index or restructure to trailing: LIKE 'term%'."
            )

    def analyze(self, query: str) -> AnalysisReport:
        report = AnalysisReport(query=query)
        norm   = re.sub(r"\s+", " ", query.strip().upper())
        for rule in self._all_rules():
            issue = rule(norm, query)
            if issue: report.add(issue)
        return report