postgres-patterns

Provide PostgreSQL optimization patterns with SQL examples for indexing and security.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/YosefHayim/Template --skill postgres-patterns-yosefhayim
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgres-patterns
Source: https://github.com/YosefHayim/Template/tree/main/.cursor/skills/postgres-patterns
Command: npx skills add https://github.com/YosefHayim/Template --skill postgres-patterns-yosefhayim

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides best practices and quick references for optimizing PostgreSQL database performance, schema design, indexing, and security, helping developers write more efficient and robust SQL.

Core Features & Use Cases

  • Index Optimization: Quick reference for choosing the right index type (B-tree, GIN, BRIN) based on query patterns.
  • Data Type Selection: Guidance on appropriate PostgreSQL data types for various use cases (IDs, strings, timestamps, money, booleans).
  • Pattern Examples: Demonstrates effective patterns like composite indexes, covering indexes, partial indexes, Row Level Security (RLS), UPSERT, cursor pagination, and queue processing.
  • Anti-Pattern Detection: Provides SQL queries to identify common issues like unindexed foreign keys, slow queries, and table bloat.
  • Configuration Template: Offers a starting point for essential PostgreSQL configuration settings.

Quick Start

Use the postgres-patterns skill to generate an optimized composite index for a query filtering by status and sorting by creation date.

Frequently Asked Questions about postgres-patterns

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

FAQPage Schema
How do I choose the right PostgreSQL index type for my query patterns?

PostgreSQL index selection depends on query patterns: B-tree for standard sorting and equality, GIN for full-text or array searches, and BRIN for large tables with naturally sorted data. The skill provides SQL examples for each strategy.

How do I implement Row Level Security policies in PostgreSQL?

Implementing Row Level Security in PostgreSQL involves defining RLS policies via SQL to restrict row-level data access. This skill provides specific SQL examples for creating RLS policies based on Supabase guidelines.

What is the best way to detect unindexed foreign keys and table bloat in PostgreSQL?

Detecting unindexed foreign keys and table bloat requires running anti-pattern detection SQL queries. This skill provides specific SQL queries to identify these common PostgreSQL performance bottlenecks and schema design issues.

How do I write a PostgreSQL UPSERT query and set up cursor pagination?

Writing a PostgreSQL UPSERT query and setting up cursor pagination requires specific SQL syntax for conflict handling and keyset pagination. This skill demonstrates effective SQL pattern examples for both operations.

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

For PostgreSQL data types, use appropriate identifiers for IDs, timestamp types for temporal data, and numeric formats for money. This skill offers guidance on selecting the correct data types for these specific database use cases.