Database Query Performance
ASecurityNot 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
Works with
Security analysis
100/100Pro scans all 7 files and shows the line behind each finding
npx -y skills add HoangNguyen0403/agent-skills-standard --skill database-query-performance --agent claude-codeAre you the author of Database Query Performance?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/hoangnguyen0403-database-query-performance)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.md
- eval-1.with-skill.md
- trigger-1.md
- trigger-2.md
- trigger-3.md
- trigger-4.md
Attribution
Related skills
View all in development →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.