Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    SQL Query Review & Optimization

    1

    Review SQL joins, aggregation, NULL behavior, and optimization hypotheses while protecting the intended result.

    $29

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    SQL Query Review & Optimization

    SQL Query Review & Optimization

    Example session with this skill installed

    Review this PostgreSQL query. Orders has one row per order; Payments and OrderLines each contain multiple rows per order. I need one row per order with the sum of captured payments and line amounts. SELECT o.id, SUM(p.amount) AS paid, SUM(l.amount) AS lines FROM Orders o LEFT JOIN Payments p ON p.order_id=o.id AND p.status='captured' LEFT JOIN OrderLines l ON l.order_id=o.id GROUP BY o.id; For order 1, captured payments are 20 and 30, and lines are 10, 15, 25. No database connection is available.

    • Read your context and instructions
    • Compiled the sql query review

    High priority: the two child joins multiply each other before SUM. For the supplied fixture, the joined rows produce paid=150 and lines=100; the required result is paid=50 and lines=50. This follows from the stated cardinalities and arithmetic; no query was executed.

    Aggregate each child to order grain first

    SELECT o.id, COALESCE(p.paid, 0) AS paid,
           COALESCE(l.lines, 0) AS lines
    FROM Orders o
    LEFT JOIN (
      SELECT order_id, SUM(amount) AS paid
      FROM Payments WHERE status = 'captured' GROUP BY order_id
    ) p ON p.order_id = o.id
    LEFT JOIN (
      SELECT order_id, SUM(amount) AS lines
      FROM OrderLines GROUP BY order_id
    ) l ON l.order_id = o.id;
    

    COALESCE assumes a missing child means zero; omit it if the business policy requires NULL. Check order 1 for 50/50, an order without children for 0/0, and an order with uncaptured payments for their exclusion. All checks remain unexecuted. No performance improvement is measured; inspect a representative plan before adding indexes.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Review SQL joins, aggregation, NULL behavior, and optimization hypotheses while protecting the intended result.

    What you receive

    Prioritized query findings, a dialect-aware correction, explained equivalence conditions, and duplicate-sensitive validation cases.

    When to use it

    Review supplied SQL queries for correctness and conditional performance improvements. Use for joins, aggregation, NULL behavior, and query plan interpretation; identify the database dialect before proposing dialect-specific syntax.

    What to provide

    Supply the relevant code, schema, design notes, brief, or evidence together with the intended business result and constraints. Sanitized examples are sufficient to begin. The agent identifies missing details that materially affect the recommendation and labels conditional conclusions.

    Boundaries

    This is an advisory workflow for supplied evidence. It does not connect to a database, tenant, production system, or business application by itself. Runtime execution, deployment, remediation, and external actions are not included. No benchmark, security certification, compliance approval, or business outcome is guaranteed. Proposed validation remains unexecuted unless separately run with authorized tools.

    Package

    One SKILL.md with the complete workflow. One-time purchase. Your AI assistant and any source-system licenses are separate.

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Data & Databases.

    Static review only. Cannot access live databases or execute DDL. Performance suggestions are hypotheses requiring EXPLAIN ANALYZE for verification. Validates logic, not hardware performance.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 21 days ago

    Nothing to install. It runs in your AI agent.

    Static review needs nothing extra. Running the queries needs your own runtime, licenses and authorized access.

    Permissions

    Write Files
    Read Files

    Read only user-authorized input files when provided; pasted input is sufficient. Write review artifacts only when requested. No unrestricted network access, credentials, live system changes, or automatic query execution are required.

    Listed21 days ago

    What's inside

    Frequently Asked Questions

    This skill identifies semantic defects that syntax checkers miss, such as join fanouts that duplicate data, NULL-handling errors in three-valued logic, and timezone-related data corruption.

    The skill supports major dialects including PostgreSQL, SQL Server, and MySQL, along with M code (Power Query), focusing on engine-specific logic and SARGability.

    No live connection is required; the skill performs a static analysis based on the SQL code, schema metadata, and business logic you provide.

    It is specifically designed to detect 'fanout,' where joining multiple child tables to one parent causes aggregated sums to multiply incorrectly—a common issue standard AI prompts often overlook.

    You will receive the core logic for the SQL Query Review skill, including specialized analysis protocols for identifying semantic risks and optimizing predicates.

    While it provides optimized predicates for better performance, the primary focus is on data integrity and correctness; it does not provide execution-time benchmarks.

    New in Data & Databases