Skip to content
Back to skills

Data Operations

ASecurity

Postgres query optimization and data seeding: EXPLAIN ANALYZE, N+1, cursor pagination, CTEs, factories, fixtures.

  • 3 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added November 14, 2026
databasesgobashsqldatabaseperformance

Works with

  • cursor

Security analysis

A100/100

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

Scanned November 14, 2026

npx -y skills add SebastianLuser/claude-code-arcane --skill data-operations --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Data Operations?

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

Security grade badge for Data Operations
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/sebastianluser-data-operations/badge)](https://www.skillsdirectory.com/skills/sebastianluser-data-operations)

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: data-operations
description: "Postgres query optimization and data seeding: EXPLAIN ANALYZE, N+1, cursor pagination, CTEs, factories, fixtures."
category: "database"
argument-hint: "[optimize <query>|seed <env>]"
user-invocable: true
allowed-tools: Read, Glob, Grep, Bash, Write, Edit, Task
---
# data-operations — Query Optimization & Seeding

## Route

| User intent | Mode | Section |
|----------------------|------|---------|
| "slow query", "EXPLAIN", "N+1", "optimize SQL", "OFFSET", "index" | OPTIMIZE | → Section 1: Query Optimization |
| "seed", "fixtures", "demo data", "faker", "factory", "test data", "anonymize" | SEED | → Section 2: Data Seeding |

**Rule:** if the intent is ambiguous, ask before running anything.

---

## When to use

Diagnose/optimize slow queries, create dev/test/staging seeders, anonymize prod dumps.

## 1. Query Optimization

### EXPLAIN first

Always: `EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT) <query>;`. Visualize complex plans: explain.dalibo.com. Top queries: `pg_stat_statements ORDER BY total_exec_time DESC LIMIT 20`.

> → Read references/query-optimization.md for EXPLAIN signal table, common problems (N+1, SELECT *, OFFSET, etc.), CTEs, LATERAL joins, and materialized views

## 2. Data Seeding

4 types: Reference (all envs), Dev fixtures (local), Test fixtures (CI), Demo (staging). Structure: `db/seeds/` with reference/, fixtures/, demo/, anonymize/. Key rules: upserts for idempotency, factory pattern, anti-prod guardrail (`APP_ENV != "production"`).

> → Read references/seeding.md for seeding types, structure, factory patterns, performance tips, and anonymization guide

## Anti-patterns

> → Read references/anti-patterns.md for query (5 items) and seeding (5 items) anti-patterns

## Checklist

### Query optimization
- [ ] EXPLAIN ANALYZE before and after
- [ ] pg_stat_statements top queries reviewed
- [ ] N+1 removed (JOIN/Preload/DataLoader)
- [ ] Cursor pagination, not OFFSET
- [ ] Indexes validated → `/database-setup`

### Seeding
- [ ] Reference data separate from fixtures
- [ ] Idempotent upserts
- [ ] Anti-prod guardrail
- [ ] No real PII in fixtures
- [ ] Factory pattern for random data
- [ ] faker.seed() for deterministic tests

Files in this skill

  • SKILL.md2.2 KB
  • references/anti-patterns.md316 B
  • references/query-optimization.md2 KB
  • references/seeding.md1.2 KB

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 databases →

Comments

Loading comments…

Newsletter

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