一键导入
databases
Query optimization and migration best practices
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Query optimization and migration best practices
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | databases |
| description | Query optimization and migration best practices |
For Neon Postgres branch management, connection strings, and project operations, see the neonctl skill.
neonctl branches list, neonctl connection-string, neonctl set-contextmcp__Neon__run_sql, mcp__Neon__create_branchFor KQL queries against Azure Data Explorer or Microsoft Fabric Eventhouse, see the kusto-cli skill — connection strings, headless execution, CSV export, and the companion kusto-cli-safety rule that gates destructive control commands (.drop, .purge, .delete, .execute database script, etc.).
Kusto.Cli.exe "<conn>" -execute:"<KQL>" -keepRunning:falseNO database changes without query optimization check.
Before Writing Queries:
1. Check existing indexes
2. Estimate row counts
3. Consider query plan
4. Avoid N+1 patterns
EXPLAIN ANALYZE:
- Run on all new queries
- Watch for Seq Scan on large tables
- Check actual vs estimated rows
- Identify missing indexes
Create Index When:
- Column in WHERE clause frequently
- Column in JOIN condition
- Column in ORDER BY with LIMIT
- Unique constraints needed
Avoid Index When:
- Small tables (<1000 rows)
- High write frequency
- Low cardinality columns
- Rarely queried columns
Types:
B-tree: Default, equality and range
Hash: Equality only
GIN: Arrays, JSONB, full-text
GiST: Geometric, full-text
Pool Settings:
min: 2-5 connections
max: 10-20 connections (CPU cores * 2 + disk spindles)
idleTimeout: 10000ms
connectionTimeout: 5000ms
Best Practices:
- Always release connections
- Use transactions appropriately
- Avoid long-running transactions
- Monitor connection counts
Avoid:
SELECT * → Select specific columns
No LIMIT on lists → Always paginate
String concatenation → Use parameterized queries
No indexes on FKs → Index foreign keys
N+1 queries → Use JOINs or batch loading
Missing transactions → Wrap related writes
Normalization:
- 3NF for transactional data
- Denormalize for read-heavy analytics
- Use appropriate data types
- Add constraints (NOT NULL, CHECK, FK)
Naming:
- snake_case for tables/columns
- Plural table names (users, orders)
- Descriptive column names
- Consistent timestamp naming (created_at, updated_at)
Safe Operations:
- ADD COLUMN (nullable or with default)
- CREATE INDEX CONCURRENTLY
- ADD CONSTRAINT with NOT VALID
Dangerous Operations:
- DROP COLUMN (data loss)
- ALTER COLUMN TYPE (locks table)
- ADD COLUMN NOT NULL without default
- CREATE INDEX (locks writes)
Always:
- Test migrations on copy of prod data
- Have rollback plan
- Run during low-traffic periods
- Monitor during execution
Activation:
- Database|Query|SQL|PostgreSQL keywords
- Schema changes detected
- Performance issues with DB
- New entity creation
Persona Alignment:
- backend persona primary
- performance persona for optimization
- architect persona for schema design
ClaudeKit Skills | databases v1.0 | PostgreSQL-focused
The Code reporting discipline AND the reporting-system operations command. Discipline half — the "one spine" rule (every reportable unit of work lands one Weekly Work Tracker row, Source-tagged), field mapping, Bridge auto-mirror tie-in. Operations half (proposal 07) — /reporting status (registry tail, trust metrics, drift, next scheduled runs, log locations), /reporting run <pipeline>, /reporting heal. Use when finishing reportable work, when asked "how should I report this" / "log this for the report", at session end to capture unreported work, or for pipeline ops — "/reporting", "reporting status", "is reporting healthy", "run the health check", "why is a report row missing/stale".
Generate the weekly FourthOS sponsor update package for Carly (VP) and Christian (CTO). Pulls live portfolio data from the FourthOS Notion cockpit, refreshes the Notion Update Package page, renders a progressive-disclosure HTML artifact set (Tier 1 briefing dashboard, Tier 2 teaching deep-dive), stages it UNLISTED to the ai-enablement-decks GitHub Pages site, and notifies Dave to review before promoting it live. Use when asked to generate, build, preview, or promote the FourthOS weekly sponsor update, or when the CCv3-FourthOS-Weekly scheduled task runs. Triggers on "fourthos weekly", "sponsor update", "Carly update", "Christian update", "weekly portfolio update".
Run a feature through the full tri-model Game Plan pipeline — rostered roles (Claude hub, Grok builder/researcher, Codex reviewer/fixer), a workroom disk bus, and human gates. Use when the user types /game-plan [feature], says "run the game plan on X", "full crew on this", "roster this feature", or wants a multi-milestone feature built with cross-model build/review separation. Opt-in orchestrator on top of /workroom; for one-shot tasks use /grok or /codex directly, for trivial edits use neither.
Audit and curate the memory system -- identify signal vs noise, score entries, and archive low-quality learnings.
Detect drift between the continuous-claude repo and the active ~/.claude/ directory
Initialize Continuous Claude v3 for a new project with full toolset activation. Creates project CLAUDE.md (interview-driven, 8 sections), ROADMAP.md, knowledge tree, Serena code intelligence, and project registry entry. Use when opening a new project folder for the first time, starting a new project, setting up CCv3 in an existing repo, or the user says "init project", "setup project", "new project", "initialize", "start new project".