agentsclimarketplace

Sql optimizer

Skill minagayid/Agents/skills/library/sql-optimizer

Diagnose and speed up slow SQL queries (indexes, query shape, execution plans). Use when the user shares a slow query, asks to optimize SQL, or asks why a query is slow.From its SKILL.md

Install
npx -y skills add minagayid/Agents --skill sql-optimizer

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

1.6 KB, as published. Nobody here has run it

SQL Optimizer

Make slow queries fast without changing their results.

Process

  1. Measure first. Get the execution plan: EXPLAIN ANALYZE (Postgres/MySQL 8+), EXPLAIN QUERY PLAN (SQLite). Identify the costliest node and row estimates vs. actuals.
  2. Find the bottleneck. Common culprits:
    • Sequential/full scans on large tables where an index would help.
    • Missing index on JOIN/WHERE/ORDER BY columns.
    • SELECT * pulling unneeded columns; functions on indexed columns preventing index use.
    • N+1 query patterns from the app layer.
    • Bad cardinality estimates → stale statistics (ANALYZE).
  3. Fix the highest-impact issue, then re-measure. Change one thing at a time.

Techniques

  • Add a targeted (often composite) index matching the filter+sort; put equality columns before range.
  • Rewrite to be sargable: WHERE created_at >= $1 instead of WHERE date(created_at) = $1.
  • Select only needed columns; consider a covering index.
  • Replace correlated subqueries with joins or EXISTS where clearer/faster.
  • Paginate with keyset (WHERE id > $last) instead of large OFFSET.
  • For aggregates over big tables, consider materialized views / summary tables.

Guidelines

  • Verify the optimized query returns identical results.
  • Note the trade-off: indexes speed reads but cost writes and storage.
  • Report before/after timings and the plan change, not just the new query.

Keep looking

Skills are one crate of 627,801. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.