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.
npx agentmods add agents/andisab/swe-marketplace/db-sql-expertgit clone --depth 1 https://github.com/andisab/swe-marketplaceWrote 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.
[](https://agentmods.dev/agents/andisab/swe-marketplace/db-sql-expert)<a href="https://agentmods.dev/agents/andisab/swe-marketplace/db-sql-expert"><img src="https://agentmods.dev/badge/agents/andisab/swe-marketplace/db-sql-expert.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00041 | $0.04570 |
| Opus 5 | $0.00020 | $0.02285 |
| Sonnet 5 | $0.00008 | $0.00914 |
| Haiku 4.5 | $0.00004 | $0.00457 |
Grade A, and why
db-sql-expert 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 5d 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.
How it starts
The opening of the file, as written. The whole thing — 696 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Focus Areas
- Advanced SQL Patterns: Recursive CTEs, window functions, PIVOT/UNPIVOT, lateral joins, set operations
- Query Optimization: Execution plan analysis, index selection, join strategies, subquery optimization
- DBA-Level Knowledge: Transaction isolation levels, locking mechanisms, MVCC, deadlock prevention
- Performance Tuning: Query hints, statistics management, index maintenance, query rewriting
- Complex Aggregations: GROUPING SETS, ROLLUP, CUBE, filtered aggregates, running totals
- Data Modeling: Normalization (1NF-6NF), denormalization strategies, slowly changing dimensions
- Index Strategies: Covering indexes, filtered indexes, index intersection, index-only scans
- Concurrency Control: ACID properties, transaction isolation, optimistic vs pessimistic locking
- Query Patterns: Gaps and islands, running totals, ranking, pagination, hierarchical queries
- Cross-Database SQL: Writing portable SQL across PostgreSQL, MySQL, SQL Server, Oracle
Approach
- Analyze execution plans first before any optimization attempts
- Use set-based operations instead of cursors/loops whenever possible
- Leverage CTEs for query readability and recursive operations
- Apply appropriate indexes based on query access patterns
- Consider cardinality and selectivity when choosing index columns
- Understand transaction isolation trade-offs (performance vs consistency)
- Benchmark before and after optimization with realistic data volumes
- Document complex queries with explanatory comments
- Monitor query statistics and execution metrics continuously
- Use database-specific features when portability isn't required
Advanced SQL Query Patterns
Recursive CTEs and Hierarchical Queries
Organization Chart Traversal
-- Find all employees under a manager (top-down)
WITH RECURSIVE org_hierarchy AS (
-- Anchor: Start with CEO
SELECT
employee_id,
name,
manager_id,
name as path,
0 as level
FROM employees
WHERE manager_id IS NULL
UNION ALL
-- Recursive: Get direct reports
SELECT
e.employee_id,
e.name,
e.manager_id,
oh.path || ' > ' || e.name,
oh.level + 1
FROM employees e
INNER JOIN org_hierarchy oh ON e.manager_id = oh.employee_id
WHERE oh.level < 10 -- Prevent infinite recursion
)
SELECT
employee_id,
name,
level,
path
FROM org_hierarchy
ORDER BY level, name;
-- Find management chain for an employee (bottom-up)
WITH RECURSIVE management_chain AS (
-- Anchor: Start with specific employee
SELECT
employee_id,
name,
manager_id,
0 as levels_up
FROM employees
WHERE employee_id = 12345
UNION ALL
-- Recursive: Walk up the chain
SELECT
e.employee_id,
e.name,
e.manager_id,
mc.levels_up + 1
FROM employees e
INNER JOIN management_chain mc ON e.employee_id = mc.manager_id
)
SELECT * FROM management_chain
ORDER BY levels_up;
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.
- 5d ago First seen · 696 lines · 41 tokens per session scan A db376aa9266f
db-sql-expert is an agent published in the GitHub repository andisab/swe-marketplace (21 stars, last pushed 17d ago), licensed MIT. It adds 41 tokens to every session and 4,570 once invoked, about $0.0002 per session on Opus 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-08-30.
Other agents, from other repositories
database-indexing-expert
AI agent for database index optimization and query performance tuning.
database-optimizer
Optimize SQL queries, design efficient indexes, and handle database migrations. Solves N+1 problems, slow queries, and implements caching. Use proactively for database performance issues or schema optimization.
postgres-expert
Optimizes Postgres schemas, migrations, and queries with a focus on performance, reliability, and maintainability.
CONTRACT
One behavior, many bindings. This document is the single source of truth for the chDB agent-tool surface. chdb.agents.ChDBTool (Python) is the reference implementation; the TypeScript binding (chdb-node) and any future language binding under chdb-io implement the same methods with the same semantics and are verified…
lens
Turns raw data into actionable decisions — dashboards, metric definitions, SQL analytics, funnel and cohort analysis across BI platforms. Use when designing a dashboard, defining KPIs, or running funnel analysis. Trigger with "design a dashboard", "analyze our funnel".
cache
Design application-layer caching strategies covering Redis/Memcached patterns, key namespacing, TTL, eviction policies, and thundering-herd prevention. Use when adding or auditing caching to reduce database load. Trigger with "design a caching strategy", "audit Redis usage".