Skip to content
Back to skills

Minimal

ASecurity

Techniques for diagnosing and optimizing slow SQL queries.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 10, 2026
databasespythongosql

Security analysis

A100/100

Scanned September 10, 2026

npx -y skills add snoodleboot-io/prompticorn --skill minimal --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Minimal?

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

Security grade badge for Minimal
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/snoodleboot-io-minimal-baf403e1/badge)](https://www.skillsdirectory.com/skills/snoodleboot-io-minimal-baf403e1)

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
# SQL Optimization (Minimal)

## Purpose
Techniques for diagnosing and optimizing slow SQL queries.

## Core Techniques

### 1. EXPLAIN ANALYZE
```sql
EXPLAIN ANALYZE SELECT * FROM orders WHERE customer_id = 123;
```
Shows execution plan and actual vs. estimated rows. Look for:
- Seq Scan (full table scan) = slow for large tables
- Index Scan = good, uses index
- High Filter rows = indexes not selective enough

### 2. Add Indexes
```sql
-- Create index on frequently filtered columns
CREATE INDEX idx_orders_customer_id ON orders(customer_id);

-- Multi-column index for common filters
CREATE INDEX idx_orders_customer_date ON orders(customer_id, created_at);
```

### 3. Avoid N+1 Queries
Bad: Loop calling query for each row
```python
orders = db.query("SELECT * FROM orders")
for order in orders:
    customer = db.query("SELECT * FROM customers WHERE id = ?", order.customer_id)
    # 1 + N queries!
```

Good: Single join
```sql
SELECT o.*, c.* FROM orders o
JOIN customers c ON o.customer_id = c.id
-- 1 query!
```

### 4. Limit & Pagination
```sql
-- Don't fetch 1M rows, fetch what you need
SELECT * FROM orders LIMIT 100 OFFSET 0;
```

### 5. Use Appropriate Data Types
- Avoid TEXT for everything - use INT, DATE, etc.
- Smaller types = faster indexes
- VARCHAR(10) vs VARCHAR(1000)

## Warning Signs

- Query > 1 second
- Seq Scan on large table
- High filter ratio (estimated 1M, actual 100)
- Deadlocks in logs

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…