Skip to content
Back to skills

Query And Index Tuning

ASecurity

Tune queries with evidence: read EXPLAIN (ANALYZE, BUFFERS) first, choose the right index type and column order (B-tree/partial/composite/covering/GIN), rewrite to be sargable, kill N+1 at the SQL level, and keep statistics fresh.

  • 7 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 23, 2026
ai-agentssql

Security analysis

A100/100

Scanned September 23, 2026

npx -y skills add mcorbett51090/RavenClaude --skill query-and-index-tuning --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Query And Index Tuning?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Query And Index Tuning
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/mcorbett51090-query-and-index-tuning/badge)](https://www.skillsdirectory.com/skills/mcorbett51090-query-and-index-tuning)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: query-and-index-tuning
description: "Tune queries with evidence: read EXPLAIN (ANALYZE, BUFFERS) first, choose the right index type and column order (B-tree/partial/composite/covering/GIN), rewrite to be sargable, kill N+1 at the SQL level, and keep statistics fresh."
---

# Query & Index Tuning

## Read the plan first
`EXPLAIN (ANALYZE, BUFFERS)` — find seq scans, bad row estimates, expensive sorts/joins. Tune what it shows.

## Right index
| Predicate | Index |
|---|---|
| equality / range | **B-tree** |
| filtered subset | **partial** |
| multi-column (order by selectivity) | **composite** |
| avoid heap fetch | **covering** (INCLUDE) |
| jsonb / full-text | **GIN** |

## Or fix the query
Make it **sargable** (no function on the indexed column), avoid `SELECT *`, batch don't loop, kill N+1 with a join/`IN`.

## Stats
Stale stats cause bad plans — `ANALYZE`/autovacuum tuning fixes more than another index.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…