Master SQL query optimization, indexing strategies, and EXPLAIN analysis to dramatically improve database performance and eliminate slow queries. Use when debugging slow queries, designing database schemas, or optimizing application performance.
Install with Tessl CLI
npx tessl i github:wshobson/agents --skill sql-optimization-patterns80
Does it follow best practices?
If you maintain this skill, you can automatically optimize it using the tessl CLI to improve its score:
npx tessl skill review --optimize ./path/to/skillAgent success when using this skill
Validation for skill structure
N+1 elimination and subquery optimization
No loop queries
100%
100%
Single aggregate query
100%
100%
No correlated subquery
100%
100%
No SELECT *
100%
100%
JOIN-based aggregation
100%
100%
Filter before aggregation
100%
100%
Correct aggregation
100%
100%
CTE or subquery clarity
0%
0%
Notes explain N+1
100%
100%
Notes explain fix
100%
100%
Without context: $0.1719 · 38s · 8 turns · 9 in / 1,900 out tokens
With context: $0.4041 · 1m 48s · 17 turns · 1,225 in / 3,884 out tokens
Index design and selection strategy
GIN full-text index
100%
100%
GIN JSONB index
100%
100%
Expression index for email
100%
100%
Partial index for published status
100%
100%
Composite index column order
100%
100%
Cursor pagination index
70%
70%
Cursor-based query provided
100%
100%
No leading wildcard LIKE
100%
100%
Index type rationale
100%
100%
Selective indexing awareness
50%
40%
Without context: $0.3082 · 1m 32s · 11 turns · 12 in / 4,802 out tokens
With context: $0.4473 · 1m 36s · 19 turns · 67 in / 4,482 out tokens
Performance audit and advanced optimization
pg_stat_statements query
100%
100%
Missing index detection
80%
100%
Unused index detection
100%
100%
Materialized view creation
100%
100%
Concurrent materialized refresh
100%
100%
Batch UPDATE not loop
100%
100%
Temp table for large batch
100%
100%
pg_class approximate count
100%
100%
VACUUM ANALYZE maintenance
100%
100%
Materialized view index
100%
100%
Without context: $0.3290 · 1m 27s · 14 turns · 63 in / 4,636 out tokens
With context: $0.6473 · 2m 11s · 24 turns · 24 in / 7,133 out tokens
Table of Contents
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.