agentleFS
nainishshafinainishshafi/developer-productivity-skills/.github/skills/sql-executor/SKILL.md

sql-executor

Skill1 starsChanged 4 days agoMITView on GitHub

Practitioner guidance for querying, tuning, validating, and troubleshooting enterprise databases (SQL Server, Oracle, PostgreSQL, SQLite, MongoDB, MS Access, MySQL) via the sql-connector MCP server. Covers multi-engine joins, GIN/GiST/BRIN indexing, stored procedures, TVFs, Oracle cursors, CTEs, #temp tables, OLAP cubing, window functions, and cohort analytics. Use when asked to "write a sql join", "optimize sql query", "tune database index", "sql cube", "grouping sets", "sql cohort analysis", "postgres gin index", "oracle cursor", "sql stored procedure", "sql cte", or "run database queries".

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Before generating queries, stored procedures, or table schemas, consult detect-overengineering:

    line 29
  2. Distinctive:

    Avoid Speculative Indexes: Do not index every column proactively.

    line 30
  3. Distinctive:

    Avoid Query Ceremony: Prefer simple ANSI joins over multi-level nested CTEs unless intermediate materialization is required.

    line 31

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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

SQL Executor

Architectural heuristics and execution guidance for querying, indexing, and optimizing enterprise relational and document databases via the sql-connector MCP server.


Architectural Heuristics & Decision Matrix

Task CategoryRecommended StrategyWhen NOT to UseTrade-Offs & Rationale
Multi-Table JoinsANSI-92 joins; CROSS/OUTER APPLY (SQL Server); LATERAL (Postgres)Legacy Oracle (+); unparenthesized MS Access 3+ joinsANSI provides portable semantics; APPLY/LATERAL correlate rows without Cartesian bloat.
CTEs vs #TempTablesChained/Recursive CTEs for trees; #TempTable for $> 1,000$ rowsRe-evaluating expensive CTEs multiple times in SQL ServerCTEs inline cleanly; #TempTable provides full column histograms, indexes, and TempDB caching.
OLAP & CubingGROUP BY GROUPING SETS / ROLLUPUnbounded CUBE on $> 4$ dimensions ($2^N$ blowup)GROUPING SETS avoids combinatorial explosion of unnecessary sub-aggregations.
Specialized IndexingGIN for JSONB/trigrams; GiST for ranges; BRIN for append-only logsB-Trees on high-cardinality JSONB/text or terabyte append-only logsGIN enables containment/trigram search; BRIN gives 99% space savings on sequential data.
Stored Procedures & TVFsInline TVFs (iTVFs); parameterized sp_executesql / CALLMulti-statement TVFs (mTVFs); string concatenation SQLiTVFs inline into optimizer plans; dynamic SQL with parameters blocks SQL injection.
Oracle CursorsSYS_REFCURSOR for drivers; BULK COLLECT + LIMIT 1000Row-by-row (RBAR) loops; BULK COLLECT without LIMITBulk operations eliminate PL/SQL context switches; LIMIT prevents PGA memory exhaustion.
Window FunctionsROWS BETWEEN ... framing; DENSE_RANK() for top $N$ per groupUnbounded RANGE BETWEEN when physical rows sufficeROWS operates on physical offsets avoiding temporary disk spooling.

🛡️ Over-Engineering Self-Check (Anti-Bloat Guardrail)

Before generating queries, stored procedures, or table schemas, consult detect-overengineering:

  • Avoid Speculative Indexes: Do not index every column proactively. Only index proven predicates.
  • Avoid Query Ceremony: Prefer simple ANSI joins over multi-level nested CTEs unless intermediate materialization is required.
  • Avoid SELECT *: Explicitly specify required columns to enable Index-Only Scans.

📚 Modular Deep Topics

  • MCP Workflow & Schema Discovery — Discovery workflow, tool payloads, and connection handling.
  • Multi-Engine Joins Architecture — Dialect-specific join syntax, APPLY, LATERAL, and MS Access parentheses rules.
  • Temporary Structures, CTEs & #TempTables — Chained/Recursive CTEs, CTE materialization, #TempTable vs @TableVariable, and GTTs.
  • OLAP Cubing & Advanced Analytics — CUBE, ROLLUP, GROUPING SETS, percentiles, sessionization, and cohort retention.
  • Window Functions, TVFs & Pivoting — Analytic window functions (ROWS vs RANGE), cross-engine TVFs, and matrix pivoting.
  • Indexing & Performance Tuning — B-trees, composite ordering, sargability anti-patterns, and execution plans.
  • PostgreSQL Specialized Indexing — GIN (jsonb_ops, jsonb_path_ops, pg_trgm), GiST, and BRIN time-series indexes.
  • Stored Procedures, TVFs & Dynamic SQL — iTVFs vs mTVFs, output parameters, and sp_executesql.
  • Oracle Cursors & PL/SQL Optimization — SYS_REFCURSOR, BULK COLLECT + FORALL batching, and cursor locking.
  • Data Extraction & Validation — Uniqueness, orphan checks, nullability audits, and checksums.
  • Troubleshooting & Firewall Resolution — Resolving firewall blocks, deadlocks, and driver setup.

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.