Sql Query Assistant logo

Sql Query Assistant

Community
Omar-Obando
sql-query-assistant

Use when writing, optimizing, or debugging SQL queries for enterprise databases. Includes best practices for performance, debugging, complex query patterns, and database-agnostic approaches. Based on SQL certification standards and database performance tuning best practices.

Overview

PublisherOmar-Obando
Repositoryqwen-orchestrator
Skill namesql-query-assistant
Stars
53
Forks
13
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by Omar-Obando on GitHub. Read the source before you install it.

Installation

Install the Sql Query Assistant AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/Omar-Obando/qwen-orchestrator/tree/main/skills/sql-query-assistant
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Omar-Obando/qwen-orchestrator.git /tmp/qwen-orchestrator
mkdir -p .claude/skills
cp -r /tmp/qwen-orchestrator/skills/sql-query-assistant .claude/skills/sql-query-assistant
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Sql Query Assistant in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Sql Query Assistant on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Sql Query Assistant is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

SQL Query Assistant

Overview

This skill provides guidance for writing, optimizing, and debugging SQL queries in enterprise environments. It covers best practices for performance, query patterns, and database-specific considerations. Based on SQL certification standards and database performance tuning best practices.

When to Use

Use this skill when:

  • Writing complex SQL queries for reporting and analytics
  • Optimizing slow database queries (performance tuning)
  • Debugging query performance issues with EXPLAIN plans
  • Designing database schemas and indexes
  • Working with PostgreSQL, MySQL, SQL Server, or SQLite
  • Need to understand query execution plans and optimization
  • Implementing window functions for complex calculations
  • Creating CTEs for readable multi-step queries
  • Building efficient JOIN strategies
  • Implementing pagination for large datasets
  • Writing subqueries and correlated subqueries
  • Optimizing aggregate functions and GROUP BY clauses
  • Implementing database-specific optimizations
  • Setting up database indexes for query optimization
  • Creating materialized views for performance
  • Implementing query caching strategies
  • Debugging deadlocks and locking issues
  • Writing efficient batch processing queries
  • Implementing data warehouse star schemas
  • Building ETL pipelines with SQL
  • Creating database views for complex joins
  • Implementing recursive queries for hierarchical data
  • Optimizing full-text search queries
  • Setting up database partitioning strategies

Do NOT use this skill when:

  • Simple CRUD operations that can use an ORM
  • Using an ORM for basic queries (use ORM-specific skill)
  • Database administration tasks (backup, restore, user management)
  • Database migration scripting (use database migration skill)
  • NoSQL database queries (use NoSQL-specific skill)

Core Patterns

Query Optimization Checklist

sql
-- 1. Use EXPLAIN to analyze query plan
EXPLAIN ANALYZE SELECT * FROM orders WHERE customer_id = 1;

-- 2. Add indexes for frequently queried columns
CREATE INDEX idx_orders_customer_id ON orders(customer_id);

-- 3. Avoid SELECT *
SELECT id, name, email FROM users WHERE active = true;

-- 4. Use JOINs instead of subqueries when possible
SELECT o.id, u.name
FROM orders o
JOIN users u ON o.user_id = u.id;

-- 5. Limit result sets
SELECT * FROM orders WHERE created_at > '2024-01-01' LIMIT 100;

Common Query Patterns

sql
-- Pagination with offset
SELECT * FROM products
ORDER BY created_at DESC
LIMIT 50 OFFSET 0;

-- Window functions
SELECT
  name,
  salary,
  RANK() OVER (ORDER BY salary DESC) as rank
FROM employees;

-- CTE for complex queries
WITH sales_by_region AS (
  SELECT region, SUM(amount) as total_sales
  FROM sales
  GROUP BY region
)
SELECT region, total_sales
FROM sales_by_region
WHERE total_sales > 10000;

Database-Specific Considerations

PostgreSQL

  • Use EXPLAIN (ANALYZE, BUFFERS) for detailed analysis
  • Consider partial indexes for filtered queries
  • Use COPY for bulk imports
  • Enable pg_stat_statements for query monitoring

MySQL

  • Use EXPLAIN FORMAT=JSON for detailed analysis
  • Consider index merge optimization
  • Use INSERT DELAYED for non-critical inserts
  • Enable slow query log

SQL Server

  • Use SET SHOWPLAN_ALL ON for execution plan
  • Consider filtered indexes
  • Use BULK INSERT for bulk operations
  • Monitor with DMVs

Common Mistakes

❌ Bad: N+1 Query Problem

sql
-- Get users and their orders
SELECT * FROM users;  -- Query 1
-- Then for each user:
SELECT * FROM orders WHERE user_id = ?;  -- Query N

✅ Good: JOIN or IN clause

sql
-- Single query with JOIN
SELECT u.*, o.*
FROM users u
LEFT JOIN orders o ON u.id = o.user_id;

-- Or use IN with subquery
SELECT * FROM orders
WHERE user_id IN (SELECT id FROM users);

❌ Bad: Using Functions in WHERE Clause

sql
-- Prevents index usage
SELECT * FROM users WHERE LOWER(email) = 'test@example.com';

✅ Good: Pre-process value

sql
-- Allows index usage
SELECT * FROM users WHERE email = 'test@example.com';
-- Application converts to lowercase before query

Real-World Impact

Before this skill:

  • Queries taking 10+ seconds
  • No understanding of execution plans
  • N+1 query patterns
  • Missing indexes

After this skill:

  • Queries under 100ms
  • Understanding of query plans
  • Proper JOIN usage
  • Strategic indexing

SQL Formatting Standards

All SQL queries MUST follow this format:

sql
-- ✅ CORRECT: Uppercase keywords, one column per line, indented JOINs
SELECT
    p.id,
    p.name,
    p.email,
    r.name AS role_name
FROM
    users p
    INNER JOIN roles r ON p.role_id = r.id
WHERE
    p.status = 'active'
    AND p.deleted_at IS NULL
ORDER BY
    p.created_at DESC
LIMIT 20 OFFSET 0;
sql
-- ❌ WRONG: Lowercase, everything on one line, inline JOINs
select p.id, p.name, p.email, r.name as role_name from users p inner join roles r on p.role_id = r.id where p.status = 'active' and p.deleted_at is null order by p.created_at desc limit 20 offset 0;

Rules:

  • Keywords: UPPERCASE (SELECT, FROM, WHERE, JOIN, AND, OR, ORDER BY, etc.)
  • Columns: One per line with trailing comma
  • JOINs: Indented under FROM clause
  • WHERE conditions: One per line, AND/OR at start of line
  • Always use parameterized queries (never string concatenation)

Cross-References

  • designing-architecture - For database architecture decisions
  • analyzing-projects - For database schema analysis
  • tdd-workflow - For database testing strategies

References

Frequently asked questions

What does the Sql Query Assistant AI skill do?

Use when writing, optimizing, or debugging SQL queries for enterprise databases. Includes best practices for performance, debugging, complex query patterns, and database-agnostic approaches. Based on SQL certification standards and database performance tuning best practices.

Why use Sql Query Assistant on TypingMind?

Because you install it once and use it with any model. Sql Query Assistant is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Sql Query Assistant in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/Omar-Obando/qwen-orchestrator/tree/main/skills/sql-query-assistant. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Sql Query Assistant?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Sql Query Assistant?

As many as you like. As long as a model supports skills, you can use Sql Query Assistant with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Sql Query Assistant AI skill free?

Yes. It is published on GitHub by Omar-Obando under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇