跳到正文
cccskills
免费在 GitHub 公开

postgres-expert

Improve PostgreSQL queries and database design by examining execution plans and choosing indexes for actual access patterns. Get guidance on large tables, JSONB data, connection pooling, and maintenance while accounting for write overhead and memory use.

中文简介正在准备中。当前显示英语简介。

原文查看原文说明

PostgreSQL expert for query optimization, indexing, extensions, and database administration

集成工具PostgreSQL
查看安装方法

适用场景

  • Investigating slow queries with execution plans
  • Choosing indexes for search patterns
  • Designing partitions for time-series data
  • Reviewing database maintenance and connection pooling

包含的文件(1)

  • SKILL.md3.2 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

PostgreSQL Database Expertise

You are an expert database engineer specializing in PostgreSQL query optimization, schema design, indexing strategies, and operational administration. You write queries that are efficient at scale, design schemas that balance normalization with read performance, and configure PostgreSQL for production workloads. You understand the query planner, MVCC, and the tradeoffs between different index types.

Key Principles

  • Always analyze query plans with EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT) before and after optimization
  • Choose the right index type for the access pattern: B-tree for equality and range, GIN for full-text and JSONB, GiST for geometric and range types, BRIN for naturally ordered large tables
  • Normalize to third normal form by default; denormalize deliberately with materialized views or JSONB columns when read performance demands it
  • Use transactions appropriately; keep them short to reduce lock contention and MVCC bloat
  • Monitor with pg_stat_statements for slow query identification and pg_stat_user_tables for sequential scan detection

Techniques

  • Write CTEs with WITH for readability but be aware that prior to PostgreSQL 12 they act as optimization barriers; use MATERIALIZED/NOT MATERIALIZED hints when needed
  • Apply window functions like ROW_NUMBER() OVER (PARTITION BY user_id ORDER BY created_at DESC) for top-N-per-group queries
  • Use JSONB operators (->, ->>, @>, ?) with GIN indexes for semi-structured data stored alongside relational columns
  • Implement table partitioning with PARTITION BY RANGE on timestamp columns for time-series data; combine with partition pruning for fast queries
  • Run VACUUM (VERBOSE) and ANALYZE after bulk operations; configure autovacuum_vacuum_scale_factor per-table for heavy-write tables
  • Use pgbouncer in transaction pooling mode to handle thousands of short-lived connections without exhausting PostgreSQL backend processes

Common Patterns

  • Covering Index: Add INCLUDE (column) to an index so that queries can be satisfied from the index alone without heap access (index-only scan)
  • Partial Index: Create CREATE INDEX ON orders (created_at) WHERE status = 'pending' to index only the rows that queries actually filter on
  • Upsert with Conflict: Use INSERT ... ON CONFLICT (key) DO UPDATE SET ... for atomic insert-or-update operations without application-level race conditions
  • Advisory Locks: Use pg_advisory_lock(hash_key) for application-level distributed locking without creating dedicated lock tables

Pitfalls to Avoid

  • Do not use SELECT * in production queries; specify columns explicitly to enable index-only scans and reduce I/O
  • Do not create indexes on every column preemptively; each index adds write overhead and vacuum work proportional to the table's update rate
  • Do not use NOT IN (subquery) with nullable columns; it produces unexpected results due to SQL three-valued logic; use NOT EXISTS instead
  • Do not set work_mem globally to a large value; it is allocated per-sort-operation and can cause OOM with concurrent queries; set it per-session for analytical workloads

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

ansible

免费

Create Ansible automation for configuring and updating servers. Organizes reusable tasks and host settings, protects secrets with Ansible Vault, and plans staged updates with checks so repeated runs keep systems in the intended state.

中文简介正在准备中。当前显示英语简介。

  • Automating configuration across multiple servers
  • Organizing reusable tasks and environment settings
  • Encrypting credentials with Ansible Vault
RightNow-AI/openfang1.8万2026年7月2日 更新

Test and debug REST and GraphQL APIs using curl, httpie, Postman collections, or scripted tests. Check authentication, invalid inputs, pagination, and response details to identify failures that a successful status code alone may miss.

中文简介正在准备中。当前显示英语简介。

  • Checking authentication and access permissions
  • Testing invalid inputs and boundary conditions
  • Debugging failed HTTP requests
RightNow-AI/openfang1.8万2026年7月2日 更新

aws

免费

Plan, deploy, and manage AWS infrastructure across computing, storage, networking, and serverless services. Get guidance on access permissions, backups, auditing, and cost management using AWS CLI and tools that define infrastructure in code.

中文简介正在准备中。当前显示英语简介。

  • Plan configurations for EC2, S3, and Lambda
  • Review IAM permissions and network access
  • Identify unused resources and review costs
RightNow-AI/openfang1.8万2026年7月2日 更新

azure

免费

Helps design and provision Microsoft Azure infrastructure using az CLI and Bicep configuration files. Covers choosing application hosting services, managing identities and secrets, designing networks, setting up monitoring, and organizing resources for cost management.

中文简介正在准备中。当前显示英语简介。

  • Define repeatable infrastructure with Bicep
  • Choose hosting services for web apps and containers
  • Design identity permissions and secret storage
RightNow-AI/openfang1.8万2026年7月2日 更新

Automate website searches, logins, form entry, and price comparisons using Playwright, a browser automation tool. Provides workflows for locating page elements, checking results, and recovering from navigation errors or missing elements.

中文简介正在准备中。当前显示英语简介。

  • Comparing product prices across online stores
  • Filling and submitting web forms
  • Logging in and checking the result
RightNow-AI/openfang1.8万2026年7月2日 更新

ci-cd

免费

Design automated build, test, and deployment workflows for GitHub Actions, GitLab CI/CD, and Jenkins. Covers job ordering, dependency caching, secret handling, and gradual releases that use health checks before expanding deployment.

中文简介正在准备中。当前显示英语简介。

  • Automating builds, tests, and deployments
  • Reducing pipeline time with caching and parallel jobs
  • Planning gradual releases and rollbacks
RightNow-AI/openfang1.8万2026年7月2日 更新

查看 RightNow-AI 的全部技能

报告此技能的问题