postgres-patterns

Provide PostgreSQL patterns for query optimization, schema design, indexing, and security.

2|1|Updated Oct 4, 2025
One-click install
npx skills add https://github.com/andrew-starosciak/deep-algo --skill postgres-patterns-andrew-starosciak
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgres-patterns
Source: https://github.com/andrew-starosciak/deep-algo/tree/main/.claude/docs/zh-TW/skills/postgres-patterns
Command: npx skills add https://github.com/andrew-starosciak/deep-algo --skill postgres-patterns-andrew-starosciak

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides PostgreSQL best-practice patterns to optimize queries, design efficient schemas, and implement robust security measures. It helps teams reduce slow queries, improve data organization, and enforce consistent access controls.

Core Features & Use Cases

  • Indexing guidelines for common query patterns, including composite indexes, partial indexes, and coverage for typical workloads.
  • Data type recommendations for IDs, text, timestamps, and numeric fields to ensure performance and storage efficiency.
  • Security patterns, including Row-Level Security (RLS) and access-control considerations for multi-tenant scenarios.
  • Use Case: When designing a new relational schema with frequent range queries and access control requirements, apply these patterns to achieve predictable performance and secure access.

Quick Start

To apply these patterns, review the table of indexing guidelines and RLS recommendations, then adapt them to your existing schema and migrations.

Frequently Asked Questions about postgres-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What are the best PostgreSQL indexing patterns for query optimization?

PostgreSQL indexing patterns for query optimization include using composite indexes for multi-column queries, partial indexes for filtered subsets, and covering indexes to support typical workloads without table lookups.

How do I implement Row-Level Security in PostgreSQL for multi-tenant scenarios?

PostgreSQL Row-Level Security (RLS) for multi-tenant scenarios is implemented using policy-based access control patterns that enforce consistent data visibility rules directly at the database schema level.

What PostgreSQL data types should I use for IDs, text, and timestamps?

PostgreSQL data type recommendations for IDs, text, and timestamps focus on selecting formats that ensure both storage efficiency and high performance for your specific query patterns.

How do I design a secure and fast PostgreSQL schema with access control?

Designing a secure and fast PostgreSQL schema involves applying best-practice patterns for data types, indexing guidelines, and RLS policies to achieve predictable performance and secure multi-tenant access.

When should I use partial indexes in PostgreSQL?

Partial indexes in PostgreSQL are used when you need to optimize performance for queries that frequently target a specific, filtered subset of data within a larger table.