sql-optimization

sql-optimization is a command for GitHub Copilot from saajunaid/caddis-plugin. It costs 11 tokens per session (602 once invoked), scanned A, original, MIT.

A SQL query analyser and optimiser for improving database query performance. SQL is the language commonly used to read and change data in databases.

In plain words
What is it for?
Use it to analyse and optimise SQL across different database systems.
Why use it?
It helps find queries that may run slowly and suggests or applies performance improvements.

Command for GitHub Copilot

Written for GitHub Copilot: a Copilot chat mode or prompt.

Good fit Use it to analyse and optimise SQL across different database systems.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/saajunaid/caddis-plugin/sql-optimization
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/saajunaid/caddis-plugin

Made for: GitHub Copilot.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for sql-optimization

README.md
[![agentmods](https://agentmods.dev/badge/commands/saajunaid/caddis-plugin/sql-optimization/github.svg)](https://agentmods.dev/commands/saajunaid/caddis-plugin/sql-optimization)
Your own site
<a href="https://agentmods.dev/commands/saajunaid/caddis-plugin/sql-optimization"><img src="https://agentmods.dev/badge/commands/saajunaid/caddis-plugin/sql-optimization/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for sql-optimization

Your own site · 80×15
<a href="https://agentmods.dev/commands/saajunaid/caddis-plugin/sql-optimization"><img src="https://agentmods.dev/badge/commands/saajunaid/caddis-plugin/sql-optimization.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 11 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 602 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00011 $0.00602
Opus 5.5 $0.00004 $0.00241
Sonnet 5.5 $0.00002 $0.00120
Haiku 4.5 $0.00001 $0.00060

Measured 1mo ago against content hash f10f9cbc1374, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

sql-optimization scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.github/prompts/sql-optimization.prompt.md · 76 lines

How it starts

The opening of the file, as written. The whole thing — 76 lines — stays where its author put it; the contents beside it link to each section on GitHub.

SQL Performance Optimization

Analyze the provided SQL queries (or project SQL code) and optimize them for performance. Apply universal techniques that work across MySQL, PostgreSQL, SQL Server, Oracle, and other SQL databases.

Instructions

  1. Identify the target database engine if possible (ask if unclear).
  2. For each query or pattern found, analyze and optimize using the areas below.
  3. Show before (problematic) and after (optimized) versions with explanations.
  4. Suggest index changes where applicable.

Optimization Areas

Query Structure

  • Replace SELECT * with explicit column lists
  • Convert correlated subqueries to JOINs or window functions
  • Use EXISTS instead of IN for subqueries when appropriate
  • Filter early in WHERE clauses to reduce row processing
  • Avoid functions on indexed columns in WHERE (breaks index usage)

JOIN Optimization

  • Use INNER JOIN instead of LEFT JOIN when NULLs aren't needed
  • Move filter conditions into JOIN ... ON when logically correct
  • Order JOINs from smallest to largest result set where the optimizer benefits

Index Strategy

  • Suggest composite indexes matching query filter + sort order
  • Recommend covering indexes for frequently-run queries
  • Flag over-indexing risks (impacts write performance)
  • Consider partial indexes for filtered subsets

Pagination

  • Replace large-offset LIMIT/OFFSET with cursor-based pagination
  • Use keyset pagination (WHERE id > last_seen_id ORDER BY id LIMIT N)

Aggregation and Batching

  • Combine multiple COUNT queries into a single conditional aggregation
  • Replace row-by-row inserts with batch INSERT ... VALUES
  • Use temporary tables for complex multi-step calculations

Anti-Patterns to Flag

  • SELECT * in production queries
  • Functions wrapping indexed columns in WHERE
  • N+1 query patterns in application code
  • Missing LIMIT on unbounded queries
  • OR conditions that prevent index usage (suggest UNION ALL)

Output Format

Read the full file on GitHub · 76 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 76 lines · 11 tokens per session scan A f10f9cbc1374

Subscribe to this mod's changes

sql-optimization is a command published in the GitHub repository saajunaid/caddis-plugin (0 stars, last pushed today), licensed MIT. It adds 11 tokens to every session and 602 once invoked, about $0.0000 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-09.