[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EZ5455Q0QVASB0M4HH2PSN":3,"skill-same:01M7EZ5455Q0QVASB0M4HH2PSN":48},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":28,"commitSha":29,"skillDirectory":30,"forksCount":14,"repositoryHtmlUrl":31,"repositoryHomepageUrl":31,"ownerHtmlUrl":32,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":33,"install":34,"resources":47},"01M7EZ5455Q0QVASB0M4HH2PSN","sql-optimizer",null,"Diagnoses and fixes slow SQL queries using EXPLAIN\u002FEXPLAIN ANALYZE plan reading, index design, query rewrites, statistics, and schema-aware tuning across PostgreSQL, MySQL\u002FMariaDB, SQL Server, Oracle, and SQLite. Use this skill when a user says a query is slow, times out, \"takes forever\", needs an index, asks to \"optimize this SQL\", \"why is this query slow\", \"read this EXPLAIN plan\", \"add an index\", \"reduce query cost\", \"fix a full table scan \u002F seq scan\", \"N+1 query\", \"tune the database\", or pastes a query plan and asks what is wrong.","Mr-Nobody-Anonymous\u002FAll-skills","Mr-Nobody-Anonymous","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F184253119?v=4","01M7AEXFJHKTYQW5R0ZCQQTWFV","anonymous","01M7C00M3GQR4QKP9GZA42GFAK",0,"MIT","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fdocumentation\u002Fsql-optimizer\u002FSKILL.md",[],[],"2026-11-16 10:05:34",false,"---\nname: sql-optimizer\ndescription: Diagnoses and fixes slow SQL queries using EXPLAIN\u002FEXPLAIN ANALYZE plan reading, index design, query rewrites, statistics, and schema-aware tuning across PostgreSQL, MySQL\u002FMariaDB, SQL Server, Oracle, and SQLite. Use this skill when a user says a query is slow, times out, \"takes forever\", needs an index, asks to \"optimize this SQL\", \"why is this query slow\", \"read this EXPLAIN plan\", \"add an index\", \"reduce query cost\", \"fix a full table scan \u002F seq scan\", \"N+1 query\", \"tune the database\", or pastes a query plan and asks what is wrong.\nsource: \"https:\u002F\u002Fgithub.com\u002FJayRHa\u002FAgentSkills\"\nsource_repository: \"JayRHa\u002FAgentSkills\"\nsource_path: \"sql-optimizer\u002FSKILL.md\"\nlicense: \"MIT\"\nimported_at: \"2026-09-20\"\n---\n\n# SQL Optimizer\n\n## Overview\nThis skill turns \"this query is slow\" into a concrete, evidence-driven fix. It reads execution\nplans, identifies the dominant cost, proposes the smallest effective change (index, rewrite,\nschema, or config), and verifies the improvement with before\u002Fafter measurements.\n\nKeywords: slow query, EXPLAIN, EXPLAIN ANALYZE, query plan, seq scan, full table scan, index,\ncovering index, composite index, query rewrite, sargable, N+1, timeout, high cost, cardinality,\nstatistics, ANALYZE, query tuning, database performance, PostgreSQL, MySQL, SQL Server, Oracle, SQLite.\n\nGolden rule: **measure, change one thing, measure again.** Never guess. Never add an index\nwithout reading the plan first.\n\n## Process\nFollow these steps in order. Do not skip step 1 or 2.\n\n1. **Gather context.** Identify: the engine + version, the exact query (with real-ish parameters,\n   not placeholders), table row counts, existing indexes, and how the query is run (ORM? prepared\n   statement? batch?). If any are missing, ask or inspect the schema. See\n   `references\u002Fdialect-cheatsheet.md` for how to collect each per engine.\n\n2. **Capture the real plan.** Run the engine's analyze form to get *actual* timing and row counts,\n   not just estimates:\n   - PostgreSQL: `EXPLAIN (ANALYZE, BUFFERS, VERBOSE, FORMAT TEXT) \u003Cquery>;`\n   - MySQL 8+\u002FMariaDB: `EXPLAIN ANALYZE \u003Cquery>;` (or `EXPLAIN FORMAT=JSON`)\n   - SQL Server: `SET STATISTICS IO, TIME ON;` + Actual Execution Plan\n   - Oracle: `EXPLAIN PLAN FOR ...; SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);` then `DBMS_XPLAN.DISPLAY_CURSOR(FORMAT=>'ALLSTATS LAST')`\n   - SQLite: `EXPLAIN QUERY PLAN \u003Cquery>;`\n   Wrap writes (UPDATE\u002FDELETE) in a transaction you roll back, or test on a SELECT-shaped copy.\n\n3. **Find the dominant cost.** Read the plan bottom-up \u002F inner-most-first. Locate the node with\n   the largest `actual time` × `loops` (PostgreSQL) or highest cost\u002Frows. Compare **estimated vs\n   actual rows** — a large mismatch (>10x) means stale statistics or a bad predicate estimate.\n   Use the diagnosis table in `references\u002Fplan-reading.md`.\n\n4. **Classify the problem** into one of these buckets, then apply the matching fix:\n   - Full\u002Fsequential scan on a large table with a selective filter → add\u002Frepair an index (step 5).\n   - Index exists but unused → non-sargable predicate, type mismatch, or wrong column order (step 6).\n   - Huge row estimate mismatch → refresh statistics (`ANALYZE` \u002F `UPDATE STATISTICS`), then re-plan.\n   - Expensive sort\u002Fhash\u002Faggregate spilling to disk → covering\u002Fcomposite index or more work_mem.\n   - Nested loop with high `loops` → likely N+1 or missing join index; consider batching or a join.\n   - Returning\u002Fscanning far more rows than needed → add LIMIT, narrow SELECT list, prefilter.\n\n5. **Design indexes deliberately.** Apply the column-ordering rules (equality → range → sort →\n   include) in `references\u002Findexing-guide.md`. Prefer one well-ordered composite\u002Fcovering index\n   over many single-column ones. Estimate write\u002Fstorage cost before recommending.\n\n6. **Rewrite the query to be sargable and minimal.** Remove functions on indexed columns, fix\n   implicit casts, replace `OR` with `UNION ALL` or `IN` where it unlocks an index, turn correlated\n   subqueries into joins, push filters down, and select only needed columns. Patterns are in\n   `references\u002Frewrite-patterns.md`.\n\n7. **Verify.** Re-run the analyze form. Confirm: lower actual total time, scan replaced by index\n   seek\u002Fscan, estimate≈actual, no disk spill. Report before\u002Fafter numbers. If no improvement,\n   revert the change (especially indexes) — do not leave dead indexes behind.\n\n8. **Document.** Produce a short report: problem, root cause, change made, before\u002Fafter timing,\n   and any trade-offs (write amplification, storage). Use `templates\u002Foptimization-report.md`.\n\nOptionally run `python3 scripts\u002Fexplain_analyzer.py plan.json` to auto-flag seq scans, row\nmis-estimates, and disk spills from a PostgreSQL `FORMAT JSON` plan.\n\n## Decision Framework: which lever to pull\n- **Cheapest first.** Statistics refresh (free, instant) → query rewrite (no schema change) →\n  index (write cost) → schema change (migration) → config (`work_mem`, etc., affects everyone).\n- **Selectivity test.** An index helps only if the predicate returns a small fraction of rows\n  (rule of thumb: \u003C ~5-10% for a non-covering index). For low-selectivity filters a scan is correct.\n- **Read vs write balance.** Every index slows INSERT\u002FUPDATE\u002FDELETE and costs storage. On\n  write-heavy tables, justify each index.\n- **One change at a time.** Bundling changes makes attribution impossible.\n\n## Best Practices\n- Always test with realistic parameter values and on data volumes close to production.\n- Prefer `EXPLAIN ANALYZE` (actuals) over plain `EXPLAIN` (estimates) when safe to execute.\n- Make predicates sargable: `WHERE col = ?` not `WHERE fn(col) = ?`; range on dates not `YEAR(col)`.\n- Order composite index columns: equality predicates first, then the range\u002Fsort column.\n- Use covering indexes (INCLUDE \u002F extra key columns) to enable index-only scans on hot queries.\n- Keep the SELECT list narrow; avoid `SELECT *` in hot paths.\n- Refresh statistics after big data loads before blaming the planner.\n- For ORMs, look for N+1: one query per row in a loop → use eager loading \u002F a single join.\n- Name indexes meaningfully and record why they exist.\n\n## Common Pitfalls\n- Adding an index without reading the plan — it may never be used or may not help.\n- Trusting estimated rows when actuals differ wildly (stale stats).\n- Wrapping an indexed column in a function or casting it, killing index use.\n- Leading-column violation: a composite index `(a,b)` cannot serve a query filtering only on `b`.\n- Over-indexing: many redundant indexes crush write throughput.\n- `OR` across different columns preventing index use (rewrite to `UNION ALL`).\n- Optimizing a query that runs once instead of the one that runs millions of times — profile first.\n- Testing on tiny dev data where every plan looks fine; scans only hurt at scale.\n- Forgetting parameter sniffing \u002F plan caching differences between literal and bound values.\n\n## Bundled Files\n- `references\u002Fplan-reading.md` — how to read each engine's plan, node-by-node diagnosis table.\n- `references\u002Findexing-guide.md` — index types, column ordering, covering indexes, selectivity.\n- `references\u002Frewrite-patterns.md` — before\u002Fafter sargable rewrites and anti-patterns.\n- `references\u002Fdialect-cheatsheet.md` — per-engine commands to collect plans, stats, and metadata.\n- `scripts\u002Fexplain_analyzer.py` — flags problems in a PostgreSQL JSON plan (stdlib only).\n- `examples\u002Fslow-query-walkthrough.md` — a full worked diagnosis from plan to verified fix.\n- `templates\u002Foptimization-report.md` — fill-in report template for handing off the result.\n","# SQL Optimizer\n\n## Overview\nThis skill turns \"this query is slow\" into a concrete, evidence-driven fix. It reads execution\nplans, identifies the dominant cost, proposes the smallest effective change (index, rewrite,\nschema, or config), and verifies the improvement with before\u002Fafter measurements.\n\nKeywords: slow query, EXPLAIN, EXPLAIN ANALYZE, query plan, seq scan, full table scan, index,\ncovering index, composite index, query rewrite, sargable, N+1, timeout, high cost, cardinality,\nstatistics, ANALYZE, query tuning, database performance, PostgreSQL, MySQL, SQL Server, Oracle, SQLite.\n\nGolden rule: **measure, change one thing, measure again.** Never guess. Never add an index\nwithout reading the plan first.\n\n## Process\nFollow these steps in order. Do not skip step 1 or 2.\n\n1. **Gather context.** Identify: the engine + version, the exact query (with real-ish parameters,\n   not placeholders), table row counts, existing indexes, and how the query is run (ORM? prepared\n   statement? batch?). If any are missing, ask or inspect the schema. See\n   `references\u002Fdialect-cheatsheet.md` for how to collect each per engine.\n\n2. **Capture the real plan.** Run the engine's analyze form to get *actual* timing and row counts,\n   not just estimates:\n   - PostgreSQL: `EXPLAIN (ANALYZE, BUFFERS, VERBOSE, FORMAT TEXT) \u003Cquery>;`\n   - MySQL 8+\u002FMariaDB: `EXPLAIN ANALYZE \u003Cquery>;` (or `EXPLAIN FORMAT=JSON`)\n   - SQL Server: `SET STATISTICS IO, TIME ON;` + Actual Execution Plan\n   - Oracle: `EXPLAIN PLAN FOR ...; SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);` then `DBMS_XPLAN.DISPLAY_CURSOR(FORMAT=>'ALLSTATS LAST')`\n   - SQLite: `EXPLAIN QUERY PLAN \u003Cquery>;`\n   Wrap writes (UPDATE\u002FDELETE) in a transaction you roll back, or test on a SELECT-shaped copy.\n\n3. **Find the dominant cost.** Read the plan bottom-up \u002F inner-most-first. Locate the node with\n   the largest `actual time` × `loops` (PostgreSQL) or highest cost\u002Frows. Compare **estimated vs\n   actual rows** — a large mismatch (>10x) means stale statistics or a bad predicate estimate.\n   Use the diagnosis table in `references\u002Fplan-reading.md`.\n\n4. **Classify the problem** into one of these buckets, then apply the matching fix:\n   - Full\u002Fsequential scan on a large table with a selective filter → add\u002Frepair an index (step 5).\n   - Index exists but unused → non-sargable predicate, type mismatch, or wrong column order (step 6).\n   - Huge row estimate mismatch → refresh statistics (`ANALYZE` \u002F `UPDATE STATISTICS`), then re-plan.\n   - Expensive sort\u002Fhash\u002Faggregate spilling to disk → covering\u002Fcomposite index or more work_mem.\n   - Nested loop with high `loops` → likely N+1 or missing join index; consider batching or a join.\n   - Returning\u002Fscanning far more rows than needed → add LIMIT, narrow SELECT list, prefilter.\n\n5. **Design indexes deliberately.** Apply the column-ordering rules (equality → range → sort →\n   include) in `references\u002Findexing-guide.md`. Prefer one well-ordered composite\u002Fcovering index\n   over many single-column ones. Estimate write\u002Fstorage cost before recommending.\n\n6. **Rewrite the query to be sargable and minimal.** Remove functions on indexed columns, fix\n   implicit casts, replace `OR` with `UNION ALL` or `IN` where it unlocks an index, turn correlated\n   subqueries into joins, push filters down, and select only needed columns. Patterns are in\n   `references\u002Frewrite-patterns.md`.\n\n7. **Verify.** Re-run the analyze form. Confirm: lower actual total time, scan replaced by index\n   seek\u002Fscan, estimate≈actual, no disk spill. Report before\u002Fafter numbers. If no improvement,\n   revert the change (especially indexes) — do not leave dead indexes behind.\n\n8. **Document.** Produce a short report: problem, root cause, change made, before\u002Fafter timing,\n   and any trade-offs (write amplification, storage). Use `templates\u002Foptimization-report.md`.\n\nOptionally run `python3 scripts\u002Fexplain_analyzer.py plan.json` to auto-flag seq scans, row\nmis-estimates, and disk spills from a PostgreSQL `FORMAT JSON` plan.\n\n## Decision Framework: which lever to pull\n- **Cheapest first.** Statistics refresh (free, instant) → query rewrite (no schema change) →\n  index (write cost) → schema change (migration) → config (`work_mem`, etc., affects everyone).\n- **Selectivity test.** An index helps only if the predicate returns a small fraction of rows\n  (rule of thumb: \u003C ~5-10% for a non-covering index). For low-selectivity filters a scan is correct.\n- **Read vs write balance.** Every index slows INSERT\u002FUPDATE\u002FDELETE and costs storage. On\n  write-heavy tables, justify each index.\n- **One change at a time.** Bundling changes makes attribution impossible.\n\n## Best Practices\n- Always test with realistic parameter values and on data volumes close to production.\n- Prefer `EXPLAIN ANALYZE` (actuals) over plain `EXPLAIN` (estimates) when safe to execute.\n- Make predicates sargable: `WHERE col = ?` not `WHERE fn(col) = ?`; range on dates not `YEAR(col)`.\n- Order composite index columns: equality predicates first, then the range\u002Fsort column.\n- Use covering indexes (INCLUDE \u002F extra key columns) to enable index-only scans on hot queries.\n- Keep the SELECT list narrow; avoid `SELECT *` in hot paths.\n- Refresh statistics after big data loads before blaming the planner.\n- For ORMs, look for N+1: one query per row in a loop → use eager loading \u002F a single join.\n- Name indexes meaningfully and record why they exist.\n\n## Common Pitfalls\n- Adding an index without reading the plan — it may never be used or may not help.\n- Trusting estimated rows when actuals differ wildly (stale stats).\n- Wrapping an indexed column in a function or casting it, killing index use.\n- Leading-column violation: a composite index `(a,b)` cannot serve a query filtering only on `b`.\n- Over-indexing: many redundant indexes crush write throughput.\n- `OR` across different columns preventing index use (rewrite to `UNION ALL`).\n- Optimizing a query that runs once instead of the one that runs millions of times — profile first.\n- Testing on tiny dev data where every plan looks fine; scans only hurt at scale.\n- Forgetting parameter sniffing \u002F plan caching differences between literal and bound values.\n\n## Bundled Files\n- `references\u002Fplan-reading.md` — how to read each engine's plan, node-by-node diagnosis table.\n- `references\u002Findexing-guide.md` — index types, column ordering, covering indexes, selectivity.\n- `references\u002Frewrite-patterns.md` — before\u002Fafter sargable rewrites and anti-patterns.\n- `references\u002Fdialect-cheatsheet.md` — per-engine commands to collect plans, stats, and metadata.\n- `scripts\u002Fexplain_analyzer.py` — flags problems in a PostgreSQL JSON plan (stdlib only).\n- `examples\u002Fslow-query-walkthrough.md` — a full worked diagnosis from plan to verified fix.\n- `templates\u002Foptimization-report.md` — fill-in report template for handing off the result.\n",{"name":5,"source":24,"license":15,"description":7,"imported_at":25,"source_path":26,"source_repository":27},"https:\u002F\u002Fgithub.com\u002FJayRHa\u002FAgentSkills","2026-09-20","sql-optimizer\u002FSKILL.md","JayRHa\u002FAgentSkills","main","2d1750717747097b602acf30bd09a7cbd4b4c6ea","awesome_skills\u002Fdocumentation\u002Fsql-optimizer","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous","2026-11-09 11:45:36",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill sql-optimizer",{"tool":40,"command":41},"bunx","bunx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill sql-optimizer",{"tool":43,"command":44},"pnpm","pnpm dlx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill sql-optimizer","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fdocumentation\u002Fsql-optimizer\u002FSKILL.md",true,[],[49,56,63,70,77,84],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":19},"01M7FFFZPC2025JQQHPHDX154J","dei-assessment","Assess diversity, equity, and inclusion with metrics. TRIGGERS - Use when user needs help with dei-assessment related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fdei-assessment\u002FSKILL.md",[],[],{"skillNo":57,"name":58,"nameZh":6,"description":59,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":19},"01M7FFFWN8H4WA7A6Y398QKB6J","dei-action-plan","Create DEI action plans with goals and initiatives. TRIGGERS - Use when user needs help with dei-action-plan related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fdei-action-plan\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":19},"01M7FFFSHTM0QZRVZ2NRJTJ0PY","culture-fit-assessment","Design culture add assessment processes. TRIGGERS - Use when user needs help with culture-fit-assessment related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fculture-fit-assessment\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M7FFFMA12RKEQA38KHJSXXPS","cowork-to-code-bridge","Use an already-installed, independently verified cowork-to-code bridge to run narrowly approved actions on the user's own macOS, Linux, or WSL2 machine through a local file queue.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcowork-to-code-bridge\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":19},"01M7FFFH1F6M8YRGW5V487GH1K","counter-offer-response","Draft counter-offer responses for retention. TRIGGERS - Use when user needs help with counter-offer-response related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcounter-offer-response\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M7FFFDGEHV8Y7J9N40HZXW52","continuous-feedback-system","Design continuous feedback systems. TRIGGERS - Use when user needs help with continuous-feedback-system related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcontinuous-feedback-system\u002FSKILL.md",[],[]]