Skip to content
Back to skills

Database Query Performance

ASecurity

Not yet. Do not add “another index” until you know the exact query shape and access path. Start with evidence: - capture the exact SQL (or ORM-generated SQL), - include real filter parameters, - check how the list is sorted and paginated, - run `EXPLAIN` or `EXPLAIN ANALYZE`. That tells you whether the slowdown is actually caused by: - a full table scan, - an inefficient sort, - a bad join order, - missing index coverage, - offset pagination scanning too deeply, - or an N+1 fetch pattern arou...

  • 584 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added September 5, 2026
developmentgosqldatabase

Works with

  • cursor

Security analysis

A100/100

Pro scans all 7 files and shows the line behind each finding

Scanned September 5, 2026

npx -y skills add HoangNguyen0403/agent-skills-standard --skill database-query-performance --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Database Query Performance?

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

Security grade badge for Database Query Performance
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hoangnguyen0403-database-query-performance/badge)](https://www.skillsdirectory.com/skills/hoangnguyen0403-database-query-performance)

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
Not yet. Do not add “another index” until you know the exact query shape and access path.

Start with evidence:

- capture the exact SQL (or ORM-generated SQL),
- include real filter parameters,
- check how the list is sorted and paginated,
- run `EXPLAIN` or `EXPLAIN ANALYZE`.

That tells you whether the slowdown is actually caused by:

- a full table scan,
- an inefficient sort,
- a bad join order,
- missing index coverage,
- offset pagination scanning too deeply,
- or an N+1 fetch pattern around related order data.

Only add an index if it maps to a specific query path. For an orders listing, the useful index usually follows the query’s actual pattern, for example:

- filters: `status`, `customer_id`, `created_at`
- sort: `created_at DESC`
- joins: foreign keys used in the listing

So if the query is:

```sql
SELECT id, status, total, created_at
FROM orders
WHERE customer_id = ?
  AND status = ?
ORDER BY created_at DESC
LIMIT 50;
```

then an index like `(customer_id, status, created_at DESC)` may help because it matches the filter and sort path. But that conclusion should come from the explain plan, not guessing.

Also check the tradeoff: every new index adds write cost on inserts and updates. A good index must have a clear owner query and enough read benefit to justify that maintenance overhead.

If the plan shows the query already uses an index, the real fix may be:

- selecting fewer columns,
- switching from offset pagination to cursor/keyset pagination,
- batching related lookups to remove N+1 behavior,
- or rewriting the query shape so the database can use the right access path.

Recommended approach:

1. Inspect the exact query and parameters.
2. Run `EXPLAIN` / `EXPLAIN ANALYZE`.
3. Identify whether the bottleneck is scan, sort, join, pagination, or N+1.
4. Add or adjust an index only if it directly supports that named query path.

So the answer is: no, do not “just add another index.” Review the plan first, then add a query-owned index only if the evidence says it is the real fix.

Files in this skill

  • eval-1.baseline.md2.2 KB
  • eval-1.with-skill.md2 KB
  • trigger-1.md163 B
  • trigger-2.md128 B
  • trigger-3.md131 B
  • trigger-4.md136 B

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.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.