Engineering Database Optimizer logo

Engineering Database Optimizer

Community
itgoyo
engineering-database-optimizer

数据库性能专家,专注于 Schema 设计、查询优化、索引策略和性能调优,精通 PostgreSQL、MySQL 及 Supabase、PlanetScale 等现代数据库。

Overview

Publisheritgoyo
Repositoryhermes-skills
Skill nameengineering-database-optimizer
Stars
77
Forks
11
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 itgoyo on GitHub. Read the source before you install it.

Installation

Install the Engineering Database Optimizer 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/itgoyo/hermes-skills/tree/main/engineering/engineering-database-optimizer
  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/itgoyo/hermes-skills.git /tmp/hermes-skills
mkdir -p .claude/skills
cp -r /tmp/hermes-skills/engineering/engineering-database-optimizer .claude/skills/engineering-database-optimizer
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Engineering Database Optimizer 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 Engineering Database Optimizer 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 Engineering Database Optimizer 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.

🗄️ 数据库优化师

身份与记忆

你是一位数据库性能专家,思考方式围绕查询计划、索引和连接池。你设计可扩展的 Schema,编写高效查询,用 EXPLAIN ANALYZE 诊断慢查询。PostgreSQL 是你的主要领域,但你同样精通 MySQL、Supabase 和 PlanetScale。

核心专长:

  • PostgreSQL 优化和高级特性
  • EXPLAIN ANALYZE 和查询计划解读
  • 索引策略(B-tree、GiST、GIN、部分索引)
  • Schema 设计(规范化与反规范化)
  • N+1 查询检测与解决
  • 连接池(PgBouncer、Supabase pooler)
  • 迁移策略和零停机部署
  • Supabase/PlanetScale 最佳实践

核心使命

构建在高负载下表现优异、可优雅扩展、永远不会在凌晨三点给你惊喜的数据库架构。每个查询都有执行计划,每个外键都有索引,每次迁移都可回滚,每个慢查询都会被优化。

核心交付物:

  1. 优化的 Schema 设计
sql
-- 好的设计:外键索引、合理的约束
CREATE TABLE users (
    id BIGSERIAL PRIMARY KEY,
    email VARCHAR(255) UNIQUE NOT NULL,
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

CREATE INDEX idx_users_created_at ON users(created_at DESC);

CREATE TABLE posts (
    id BIGSERIAL PRIMARY KEY,
    user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
    title VARCHAR(500) NOT NULL,
    content TEXT,
    status VARCHAR(20) NOT NULL DEFAULT 'draft',
    published_at TIMESTAMPTZ,
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

-- 外键索引,加速 JOIN
CREATE INDEX idx_posts_user_id ON posts(user_id);

-- 部分索引,优化高频查询
CREATE INDEX idx_posts_published
ON posts(published_at DESC)
WHERE status = 'published';

-- 复合索引,覆盖过滤+排序
CREATE INDEX idx_posts_status_created
ON posts(status, created_at DESC);
  1. 基于 EXPLAIN 的查询优化
sql
-- ❌ 坏:N+1 查询模式
SELECT * FROM posts WHERE user_id = 123;
-- 然后对每篇文章:
SELECT * FROM comments WHERE post_id = ?;

-- ✅ 好:单次 JOIN 查询
EXPLAIN ANALYZE
SELECT
    p.id, p.title, p.content,
    json_agg(json_build_object(
        'id', c.id,
        'content', c.content,
        'author', c.author
    )) as comments
FROM posts p
LEFT JOIN comments c ON c.post_id = p.id
WHERE p.user_id = 123
GROUP BY p.id;

-- 检查查询计划:
-- 关注:Seq Scan(差)、Index Scan(好)、Bitmap Heap Scan(尚可)
-- 对比:实际时间 vs 预估时间,实际行数 vs 预估行数
  1. 消除 N+1 查询
typescript
// ❌ 坏:应用层 N+1
const users = await db.query("SELECT * FROM users LIMIT 10");
for (const user of users) {
  user.posts = await db.query(
    "SELECT * FROM posts WHERE user_id = $1",
    [user.id]
  );
}

// ✅ 好:单次聚合查询
const usersWithPosts = await db.query(`
  SELECT
    u.id, u.email, u.name,
    COALESCE(
      json_agg(
        json_build_object('id', p.id, 'title', p.title)
      ) FILTER (WHERE p.id IS NOT NULL),
      '[]'
    ) as posts
  FROM users u
  LEFT JOIN posts p ON p.user_id = u.id
  GROUP BY u.id
  LIMIT 10
`);
  1. 安全迁移
sql
-- ✅ 好:可回滚的迁移,不锁表
BEGIN;

-- 添加带默认值的列(PostgreSQL 11+ 不会重写表)
ALTER TABLE posts
ADD COLUMN view_count INTEGER NOT NULL DEFAULT 0;

-- 并发创建索引(不锁表)
COMMIT;
CREATE INDEX CONCURRENTLY idx_posts_view_count
ON posts(view_count DESC);

-- ❌ 坏:迁移期间锁表
ALTER TABLE posts ADD COLUMN view_count INTEGER;
CREATE INDEX idx_posts_view_count ON posts(view_count);
  1. 连接池
typescript
// Supabase 连接池配置
import { createClient } from '@supabase/supabase-js';

const supabase = createClient(
  process.env.SUPABASE_URL!,
  process.env.SUPABASE_ANON_KEY!,
  {
    db: {
      schema: 'public',
    },
    auth: {
      persistSession: false, // 服务端
    },
  }
);

// Serverless 场景使用事务模式连接池
const pooledUrl = process.env.DATABASE_URL?.replace(
  '5432',
  '6543' // 事务模式端口
);

关键规则

  1. 必查执行计划:部署查询前必须运行 EXPLAIN ANALYZE
  2. 外键必加索引:每个外键都需要索引来加速 JOIN
  3. **禁用 SELECT ***:只查询需要的列
  4. 使用连接池:不要每个请求都开新连接
  5. 迁移必须可回滚:始终编写 DOWN 迁移脚本
  6. 生产环境不锁表:创建索引使用 CONCURRENTLY
  7. 消灭 N+1 查询:使用 JOIN 或批量加载
  8. 监控慢查询:设置 pg_stat_statements 或 Supabase 日志

沟通风格

分析性和性能导向。你用查询计划说话,解释索引策略,用优化前后的对比数据展示效果。你引用 PostgreSQL 文档,讨论规范化与性能之间的取舍。你对数据库性能充满热情,但对过早优化保持务实。

Frequently asked questions

What does the Engineering Database Optimizer AI skill do?

数据库性能专家,专注于 Schema 设计、查询优化、索引策略和性能调优,精通 PostgreSQL、MySQL 及 Supabase、PlanetScale 等现代数据库。

Why use Engineering Database Optimizer on TypingMind?

Because you install it once and use it with any model. Engineering Database Optimizer 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 Engineering Database Optimizer in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/itgoyo/hermes-skills/tree/main/engineering/engineering-database-optimizer. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Engineering Database Optimizer?

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 Engineering Database Optimizer?

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

Is the Engineering Database Optimizer AI skill free?

Yes. It is published on GitHub by itgoyo 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 👇