SQL Optimization Patterns
ynulihao/AgentSkillOS
Master SQL query optimization, indexing strategies, and EXPLAIN analysis to dramatically improve database performance and eliminate slow queries.
A Data Engineering interviewer focused on database performance.
$ npx skills add PrepLabsAI/InterviewMentor --skill sql-optimization-interviewer -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install PrepLabsAI/InterviewMentor sql-optimization-interviewer --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/PrepLabsAI/InterviewMentor.git skills-src && mkdir -p .claude/skills && cp -r skills-src/agents/data-engineer/sql-optimization-interviewer .claude/skills/sql-optimization-interviewer && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "sql-optimization-interviewer" agent skill from https://github.com/PrepLabsAI/InterviewMentor/tree/main/agents/data-engineer/sql-optimization-interviewer into .claude/skills/sql-optimization-interviewer/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "sql-optimization-interviewer", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/PrepLabsAI/InterviewMentor/tree/main/agents/data-engineer/sql-optimization-interviewerType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add PrepLabsAI/InterviewMentor --skill sql-optimization-interviewer -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install PrepLabsAI/InterviewMentor sql-optimization-interviewer --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/PrepLabsAI/InterviewMentor.git skills-src && mkdir -p .agents/skills && cp -r skills-src/agents/data-engineer/sql-optimization-interviewer .agents/skills/sql-optimization-interviewer && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "sql-optimization-interviewer" agent skill from https://github.com/PrepLabsAI/InterviewMentor/tree/main/agents/data-engineer/sql-optimization-interviewer into .agents/skills/sql-optimization-interviewer/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "sql-optimization-interviewer", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add PrepLabsAI/InterviewMentor --skill sql-optimization-interviewer -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install PrepLabsAI/InterviewMentor sql-optimization-interviewer --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/PrepLabsAI/InterviewMentor.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/agents/data-engineer/sql-optimization-interviewer .cursor/skills/sql-optimization-interviewer && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "sql-optimization-interviewer" agent skill from https://github.com/PrepLabsAI/InterviewMentor/tree/main/agents/data-engineer/sql-optimization-interviewer into .cursor/skills/sql-optimization-interviewer/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "sql-optimization-interviewer", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/PrepLabsAI/InterviewMentor.git --path agents/data-engineer/sql-optimization-interviewer--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add PrepLabsAI/InterviewMentor --skill sql-optimization-interviewer -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install PrepLabsAI/InterviewMentor sql-optimization-interviewer --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/PrepLabsAI/InterviewMentor.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/agents/data-engineer/sql-optimization-interviewer .gemini/skills/sql-optimization-interviewer && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "sql-optimization-interviewer" agent skill from https://github.com/PrepLabsAI/InterviewMentor/tree/main/agents/data-engineer/sql-optimization-interviewer into .gemini/skills/sql-optimization-interviewer/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "sql-optimization-interviewer", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install PrepLabsAI/InterviewMentor sql-optimization-interviewerInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add PrepLabsAI/InterviewMentor --skill sql-optimization-interviewer -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/PrepLabsAI/InterviewMentor.git skills-src && mkdir -p .github/skills && cp -r skills-src/agents/data-engineer/sql-optimization-interviewer .github/skills/sql-optimization-interviewer && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "sql-optimization-interviewer" agent skill from https://github.com/PrepLabsAI/InterviewMentor/tree/main/agents/data-engineer/sql-optimization-interviewer into .github/skills/sql-optimization-interviewer/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "sql-optimization-interviewer", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add PrepLabsAI/InterviewMentor --skill sql-optimization-interviewer -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install PrepLabsAI/InterviewMentor sql-optimization-interviewer --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/PrepLabsAI/InterviewMentor.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/agents/data-engineer/sql-optimization-interviewer .opencode/skills/sql-optimization-interviewer && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "sql-optimization-interviewer" agent skill from https://github.com/PrepLabsAI/InterviewMentor/tree/main/agents/data-engineer/sql-optimization-interviewer into .opencode/skills/sql-optimization-interviewer/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "sql-optimization-interviewer", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
sql-optimization-interviewerA Data Engineering interviewer focused on database performance.
SQL Optimization Interviewer is an agent skill from PrepLabsAI/InterviewMentor. A Data Engineering interviewer focused on database performance. Use this agent when you need to practice analyzing slow queries, designing optimal indexes, and understanding EXPLAIN plans. It pushes you to think beyond basic SQL syntax and dive deep into how database engines actually execute your code under the hood.
Its SKILL.md is about 2.1k tokens, which your agent loads only when the skill is triggered. The skill folder holds 3 other files, including reference files (for example `references/problems.md` and `references/remotion-components.md`).
It sits in Databases, covering SQL, Data pipelines and ETL and Query optimization. It works with SQL. The repository describes itself as: AI Based mock interviews for preparing for tech jobs. The licence is MIT.
4 steps, taken from the step headings in SKILL.md.
Read from SKILL.md and the folder at commit 609d311. It shows what the files ask for, not the result of running them.
Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.
From allowed-tools in the SKILL.md frontmatter.
No scripts in the folder and no shell commands in SKILL.md (its code samples are sql).
From the folder's file list and the shell code blocks in SKILL.md.
No URLs in SKILL.md.
From URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
SQL Optimization Interviewer loads about 2.1k tokens when it runs, and up to ~6.2k if it reads all its reference files. Until then it costs about 87 tokens; SKILL.md has 819 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check found no risky patterns in SKILL.md.
Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
The full file from PrepLabsAI/InterviewMentor at commit 609d311, republished under its MIT licence (© PrepLabsAI). 819 words, ~2,130 tokens.
.claude/skills/sql-optimization-interviewer/SKILL.md (or your agent's skills folder). This skill also uses 2 other files; get the full folder from GitHub.Target Role: Data Engineer / Backend Engineer Topic: SQL Query Optimization & Database Design Difficulty: Medium to Hard
You are a senior data engineer who has optimized queries at scale (billions of rows). You're methodical, practical, and focused on real-world performance. You believe good SQL is both an art and a science. You're patient with candidates learning these concepts but expect them to think about data volume and access patterns.
When invoked, immediately begin Phase 1. Do not explain the skill, list your capabilities, or ask if the user is ready. Start the interview with a warm greeting and your first question.
Help candidates master SQL optimization and database design for data engineering interviews. Focus on:
Present a business scenario, have them design tables.
Give a slow query, have them optimize it.
At the end of the final phase, generate a scorecard table using the Evaluation Rubric below. Rate the candidate in each dimension with a brief justification. Provide 3 specific strengths and 3 actionable improvement areas. Recommend 2-3 resources for further study based on identified gaps.
SQL Query Journey:
SELECT * FROM orders WHERE customer_id = 123 AND created_at > '2024-01-01'
|
v
+-----------------+
| Parser | -> Validates syntax
+--------+--------+
v
+-----------------+
| Optimizer | -> Generates execution plan
| | - Which indexes to use?
| | - Join order?
| | - Sequential scan vs index scan?
+--------+--------+
v
+-----------------+
| Executor | -> Runs the plan
+--------+--------+
v
+-----------------+
| Storage Engine | -> Reads/writes data pages
+-----------------+B-Tree Index (Good for range queries):
[50]
/ \
[25] [75]
/ \ / \
[10] [30][60] [90]
Hash Index (Good for exact match):
Hash(customer_id=123) -> Bucket 47 -> [123: row_pointer]
Hash(customer_id=456) -> Bucket 12 -> [456: row_pointer]Scenario:
SELECT
o.order_id,
c.customer_name,
p.product_name,
o.quantity,
o.total_amount
FROM orders o
JOIN customers c ON o.customer_id = c.customer_id
JOIN products p ON o.product_id = p.product_id
WHERE o.created_at >= '2024-01-01'
AND o.status = 'completed'
ORDER BY o.total_amount DESC
LIMIT 100;Query takes 45 seconds. Orders table has 100M rows.
Hints:
-- Add composite index
CREATE INDEX idx_orders_created_status_amount
ON orders (created_at, status, total_amount DESC);
-- Covering index includes all needed columns
CREATE INDEX idx_orders_covering
ON orders (created_at, status, total_amount DESC, customer_id, product_id);Scenario: Application code fetches 1000 orders, then for each order queries the customer name separately.
Hints:
Scenario: Event logs table growing by 10M rows/day. Queries usually access last 7 days.
Hints:
CREATE TABLE events (
event_id BIGINT,
event_time TIMESTAMP,
user_id INT,
event_type VARCHAR(50),
data JSONB
) PARTITION BY RANGE (event_time);
CREATE TABLE events_2024_01_01
PARTITION OF events
FOR VALUES FROM ('2024-01-01') TO ('2024-01-02');| Area | Novice | Intermediate | Expert |
|---|---|---|---|
| Index Design | Single-column indexes only | Understands composite indexes | Designs partial, covering, and specialized indexes |
| Query Analysis | Doesn't use EXPLAIN | Reads EXPLAIN output | Optimizes based on cost model and statistics |
| Schema Design | Only normalized designs | Understands trade-offs | Designs for specific access patterns and scale |
| Performance Awareness | Ignores data volume | Mentions Big O | Discusses memory, I/O, lock contention |
| Real-World Experience | Only toy examples | Mentions monitoring | Discusses partitioning, sharding, replication |
For the complete problem bank with solutions and walkthroughs, see references/problems.md. For Remotion animation components, see references/remotion-components.md.
© PrepLabsAI, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
SKILL.md and 2 other files (references) in agents/data-engineer/sql-optimization-interviewer of PrepLabsAI/InterviewMentor.
Open the folder on GitHubat commit 609d311
SQL Optimization Interviewer next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| SQL Optimization Interviewer this skillPrepLabsAI/InterviewMentor | 112 | — | ~2.1k | Automated safety check: Pass | MIT | |
| SQL Optimization Patternsynulihao/AgentSkillOS | 617 | 10 repos | ~3.3k | Automated safety check: Pass | None | |
| SQL Database Assistantborghei/Claude-Skills | 874 | — | ~1.5k | Automated safety check: Pass | MIT | |
| Tinybird Datafile RulesTryGhost/Ghost | 55k | — | ~417 | Automated safety check: Pass | MIT | |
| Databaseaiskillstore/marketplace | 430 | 3 repos | ~1.2k | Automated safety check: Pass | None | |
| Modelersidequery/sidemantic | 129 | — | ~4.2k | Automated safety check: Pass | Apache-2.0 |
ynulihao/AgentSkillOS
Master SQL query optimization, indexing strategies, and EXPLAIN analysis to dramatically improve database performance and eliminate slow queries.
borghei/Claude-Skills
This skill should be used when the user asks to "optimize SQL queries", "explore database schemas", "generate migration SQL", "analyze query performance", or "document database structure".
TryGhost/Ghost
Rules for writing Tinybird datasources, pipes, endpoints and materialized views, with SQL constraints, optimization habits and deduplication patterns.
aiskillstore/marketplace
Database development and operations workflow covering SQL, NoSQL, database design, migrations, optimization, and data engineering.
sidequery/sidemantic
Build, validate, and manage semantic models using Sidemantic.
unxed/f4
Comprehensive guide for Go database access — parameterized queries, struct scanning, NULLable columns, transactions, isolation levels, SELECT FOR UPDATE, connection pool, batch processing, context…
PrepLabsAI/InterviewMentor
A VP of Product interviewer that simulates a product strategy interview focused on AI-native products.
PrepLabsAI/InterviewMentor
A Staff Engineer interviewer specializing in API architecture and developer experience.
PrepLabsAI/InterviewMentor
An entry-level software engineering interviewer specializing in fundamental data structures.
PrepLabsAI/InterviewMentor
An entry-level software engineering interviewer specializing in binary tree data structures.
PrepLabsAI/InterviewMentor
An on-call SRE interviewer who just got paged about a broken checkout API.
PrepLabsAI/InterviewMentor
A Senior Performance Engineer interviewer focused on caching strategies.
Works with
Categories
A Data Engineering interviewer focused on database performance. SQL Optimization Interviewer is an agent skill from PrepLabsAI/InterviewMentor. A Data Engineering interviewer focused on database performance.
SQL Optimization Interviewer fits situations like: tasks that involve SQL; tasks that involve Data pipelines and ETL; tasks that involve Query optimization.
Run `npx skills add PrepLabsAI/InterviewMentor --skill sql-optimization-interviewer -a claude-code`. Or copy the skill folder (agents/data-engineer/sql-optimization-interviewer in PrepLabsAI/InterviewMentor) into .claude/skills/sql-optimization-interviewer in your project. Claude Code loads it when a task matches its description.
Run `npx skills add PrepLabsAI/InterviewMentor --skill sql-optimization-interviewer -a codex`. Or copy the skill folder (agents/data-engineer/sql-optimization-interviewer in PrepLabsAI/InterviewMentor) into .agents/skills/sql-optimization-interviewer in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add PrepLabsAI/InterviewMentor --skill sql-optimization-interviewer -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/sql-optimization-interviewer, .gemini/skills/sql-optimization-interviewer, .github/skills/sql-optimization-interviewer and .opencode/skills/sql-optimization-interviewer in your project.
SKILL.md names no scripts, command-line tools or credentials: SQL Optimization Interviewer is instructions for the agent only.
SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.
SQL Optimization Interviewer is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.
About 2.1k tokens (SKILL.md is roughly 8.5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 4.1k tokens, read only when the agent opens those files.
Skills that share tags, products or a category with SQL Optimization Interviewer: SQL Optimization Patterns (ynulihao/AgentSkillOS, 617 stars), SQL Database Assistant (borghei/Claude-Skills, 874 stars), Tinybird Datafile Rules (TryGhost/Ghost, 55k stars) and Database (aiskillstore/marketplace, 430 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
PrepLabsAI (a GitHub organization) maintains it in PrepLabsAI/InterviewMentor, which has 112 GitHub stars. The repository holds 44 skills in this directory. The repository was last updated on October 7, 2026.
Source: PrepLabsAI/InterviewMentor on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.