agentleFS
saifoellohsaifoelloh/golang-best-practices-skill/query-performance/SKILL.md

gorm-sql-query-performance

Skill15 starsChanged 9 months agoMITView on GitHub

GORM + PostgreSQL query performance review. Use when optimizing slow queries, designing indexes, analyzing N+1 patterns, or configuring connection pools. Trigger on "slow", "optimize", "index", "EXPLAIN", "N+1", or performance degradation.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when:

    line 22

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Query Performance

Expert-level performance review for GORM + PostgreSQL queries. Detects N+1 patterns, missing indexes, connection pool misconfigurations, and memory-inefficient data fetching.

When to Apply

Use this skill when:

  • An endpoint is slow or degrading under load
  • Reviewing repository code for N+1 query patterns
  • Designing indexes for new tables or query patterns
  • Investigating connection pool exhaustion
  • Processing large datasets in background jobs

Rule Categories

PriorityCountFocus
Critical2N+1 queries, unindexed foreign keys
High3EXPLAIN ANALYZE, connection pool, batch processing
Medium2COUNT vs len(), partial indexes

Rules Covered (7 total)

Critical Issues (2)

  • critical-n-plus-one — Detect and eliminate N+1 query patterns using Preload
  • critical-unindexed-fk — Index foreign keys and all WHERE clause columns

High-Impact Patterns (3)

  • high-explain-analyze — Use EXPLAIN (ANALYZE, BUFFERS) before declaring a query optimized
  • high-connection-pool — Configure connection pool parameters explicitly for production
  • high-find-in-batches — Use FindInBatches for large dataset processing

Medium Improvements (2)

  • medium-count-query — Use db.Count instead of len() on full fetch
  • medium-partial-index — Use partial indexes for filtered queries on large tables

Trigger Phrases

  • "Why is this query slow?"
  • "Optimize this query"
  • "Check for N+1"
  • "Add an index"
  • "EXPLAIN output"
  • "Performance issue"
  • "Connection pool"
  • "Process large dataset"

Related Skills

  • gorm-query-patterns — For ORM patterns that cause N+1
  • postgresql-syntax — For ILIKE and index-aware SQL syntax
  • migration-safety — For CREATE INDEX CONCURRENTLY in migrations

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.