← Back to Skills Marketplace
ai-gaoqian

Postgres Query Optimizer

by ai-gaoqian · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ Security Clean
42
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install postgres-query-optimizer-ai
Description
AI 驱动的 PostgreSQL 查询性能优化专家。分析慢查询日志、执行计划和表结构, 推荐最优索引策略、查询重写方案和配置调优参数,覆盖全球数百万 PostgreSQL 实例。
README (SKILL.md)

PostgreSQL Query Optimizer

概述

深度 Postgres 查询优化技能,将 EXPLAIN ANALYZE 输出转化为可执行的优化方案。

核心能力

1. 执行计划分析

  • 解析 EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON) 输出
  • 识别 Seq Scan、Nested Loop 等低效算子
  • 评估行数估算偏差(Rows Removed by Filter)
  • 分析共享缓冲区命中率

2. 索引策略推荐

  • 基于查询模式推荐最优索引组合
  • 评估部分索引、覆盖索引、表达式索引适用性
  • 检测缺失索引和冗余索引
  • 生成 CREATE INDEX CONCURRENTLY 语句

3. 查询重写

  • 优化 JOIN 顺序和类型
  • 子查询转 CTE / LATERAL JOIN
  • 识别 N+1 查询模式
  • WHERE 条件优化(Sargability 检查)

4. 配置调优

  • work_mem / shared_buffers / effective_cache_size 调优
  • random_page_cost 与环境匹配分析
  • autovacuum 参数优化建议
  • 并行查询配置检查

5. 慢查询趋势分析

  • 批量分析 pg_stat_statements 数据
  • 识别性能退化趋势
  • 生成优先级排序的优化清单
  • 估算各优化方案的性能提升幅度

使用方式

分析这条慢查询: \x3CSQL 和 EXPLAIN ANALYZE 输出>
审查数据库索引: \x3C表结构 DDL 和查询模式>
优化查询性能: \x3C查询 SQL 和表行数>

输出格式

  • 问题诊断报告(严重程度、根因分析、修复方案)
  • 优化前后对比(预估执行时间、I/O 减少比例)
  • 可执行 SQL(索引创建、查询重写)

数据底座

基于 PostgreSQL 16 官方文档、The Art of PostgreSQL、Use The Index Luke、pgMustard 分析规则,覆盖 150+ 常见性能反模式和 300+ 检查规则。

定价

¥0.50 / 次优化

Usage Guidance
Install only if you are comfortable sharing the SQL, schema, and performance data you paste into the skill. Review any generated CREATE INDEX, query rewrite, or configuration advice before applying it to a real database.
Capability Assessment
Purpose & Capability
The stated purpose is to analyze user-provided PostgreSQL queries, execution plans, table structures, and performance data, then provide optimization advice and SQL suggestions. That capability is coherent and proportionate for a query optimizer skill.
Instruction Scope
The runtime instructions are limited to diagnostic analysis and recommendation output. I found no prompt override language, hidden role changes, automatic execution instructions, or unrelated behavior.
Install Mechanism
The artifact contains only one UTF-8 Markdown SKILL.md file and no executable scripts, package hooks, dependencies, or install-time commands.
Credentials
The skill may process sensitive database schemas, SQL text, EXPLAIN output, and performance statistics if the user provides them. This is expected for the purpose, but users should redact secrets and production-sensitive data.
Persistence & Privilege
The artifacts do not request credentials, session stores, privileged system access, background workers, persistence, file indexing, network access, or direct database mutation authority.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install postgres-query-optimizer-ai
  3. After installation, invoke the skill by name or use /postgres-query-optimizer-ai
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
Initial release of PostgreSQL Query Optimizer - Provides AI-driven analysis of slow query logs, execution plans, and table structures - Recommends optimal indexing strategies, query rewrites, and configuration tuning - Analyzes EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON) output for plan inefficiencies - Suggests index creation/removal, join rewrites, and N+1 query detection - Offers configuration tuning advice (work_mem, shared_buffers, autovacuum, etc.) - Supports batch analysis of pg_stat_statements to track slow query trends
Metadata
Slug postgres-query-optimizer-ai
Version 1.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is Postgres Query Optimizer?

AI 驱动的 PostgreSQL 查询性能优化专家。分析慢查询日志、执行计划和表结构, 推荐最优索引策略、查询重写方案和配置调优参数,覆盖全球数百万 PostgreSQL 实例。 It is an AI Agent Skill for Claude Code / OpenClaw, with 42 downloads so far.

How do I install Postgres Query Optimizer?

Run "/install postgres-query-optimizer-ai" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Postgres Query Optimizer free?

Yes, Postgres Query Optimizer is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Postgres Query Optimizer support?

Postgres Query Optimizer is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Postgres Query Optimizer?

It is built and maintained by ai-gaoqian (@ai-gaoqian); the current version is v1.0.0.

💬 Comments