スキル一覧に戻る
pluginagentmarketplace

postgresql-advanced-queries

by pluginagentmarketplace

PostgreSQL developer roadmap plugin with database patterns and query optimization

1🍴 0📅 2026年1月5日
GitHubで見るManusで実行

SKILL.md


name: postgresql-advanced-queries description: Master advanced PostgreSQL queries - CTEs, window functions, recursive queries version: "3.0.0" sasmp_version: "1.3.0" bonded_agent: 02-postgresql-queries bond_type: PRIMARY_BOND category: database difficulty: intermediate estimated_time: 3h

PostgreSQL Advanced Queries Skill

Atomic skill for complex query patterns

Overview

Production-ready patterns for CTEs, window functions, recursive queries, and advanced joins.

Prerequisites

  • PostgreSQL 16+
  • Intermediate SQL knowledge

Parameters

parameters:
  query_type:
    type: string
    required: true
    enum: [cte, window, recursive, lateral, aggregate]
  tables:
    type: array
    items: { type: string }

Quick Reference

CTE Pattern

WITH step1 AS (SELECT ...), step2 AS (SELECT ... FROM step1)
SELECT * FROM step2;

Window Functions

ROW_NUMBER() OVER (PARTITION BY cat ORDER BY date DESC)
SUM(amount) OVER (ORDER BY date)  -- Running total
LAG(value, 1) OVER (ORDER BY date)  -- Previous row

Recursive Query

WITH RECURSIVE tree AS (
    SELECT id, parent_id, 1 as level FROM items WHERE parent_id IS NULL
    UNION ALL
    SELECT i.id, i.parent_id, t.level + 1 FROM items i JOIN tree t ON i.parent_id = t.id
)
SELECT * FROM tree;

LATERAL Join

SELECT u.*, r.* FROM users u
CROSS JOIN LATERAL (SELECT * FROM orders WHERE user_id = u.id LIMIT 3) r;

Test Template

DO $$ DECLARE result NUMERIC; BEGIN
    CREATE TEMP TABLE test_sales (id INT, amount NUMERIC);
    INSERT INTO test_sales VALUES (1, 100), (2, 200);
    SELECT SUM(amount) OVER (ORDER BY id) INTO result FROM test_sales WHERE id = 2;
    ASSERT result = 300, 'Running total should be 300';
    DROP TABLE test_sales;
END $$;

Troubleshooting

ErrorCauseSolution
42803GROUP BY errorAdd missing columns
54001Too complexBreak into CTEs
21000Multiple rowsAdd LIMIT 1

Usage

Skill("postgresql-advanced-queries")

スコア

総合スコア

60/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です