postgres-patterns

Provide PostgreSQL indexing, schema, and security patterns based on Supabase best practices.

2|Updated Apr 1, 2024
One-click install
npx skills add https://github.com/bbaserdem/NixOS-Config --skill postgres-patterns-bbaserdem
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgres-patterns
Source: https://github.com/bbaserdem/NixOS-Config/tree/main/home-manager/batuhan/apps/claude/skills/postgres-patterns
Command: npx skills add https://github.com/bbaserdem/NixOS-Config --skill postgres-patterns-bbaserdem

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides best practices and quick reference guides for optimizing PostgreSQL database performance, schema design, indexing, and security.

Core Features & Use Cases

  • Query Optimization: Learn efficient indexing strategies and query patterns.
  • Schema Design: Understand correct data types and common design patterns.
  • Security: Implement Row Level Security (RLS) effectively.
  • Use Case: When designing a new table, consult this Skill for the optimal data types and when to use composite or partial indexes for common query patterns.

Quick Start

Use the postgres-patterns skill to generate an optimized index for a WHERE clause filtering on a JSONB column.

Frequently Asked Questions about postgres-patterns

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

FAQPage Schema
How do I optimize PostgreSQL query performance with composite or partial indexes?

To optimize PostgreSQL query performance, use composite indexes for multi-column filters and partial indexes when queries target a specific subset of rows. This Skill provides index cheat sheets and patterns to select the right strategy for common queries.

What is the best way to implement Row Level Security in PostgreSQL?

The best way to implement Row Level Security (RLS) in PostgreSQL is by defining policies that restrict data access based on user roles. This Skill provides RLS policy patterns based on Supabase best practices to secure your database tables effectively.

When do I need a covering index in PostgreSQL?

You need a covering index in PostgreSQL when your queries select specific columns that can be entirely satisfied by the index without accessing the main table. This Skill covers covering indexes and other SQL patterns to eliminate slow queries and table bloat.

Does this PostgreSQL optimization guide include UPSERT and cursor pagination patterns?

Yes, this PostgreSQL optimization guide includes common SQL patterns such as UPSERT for data insertion and cursor pagination for efficient large dataset retrieval. It also covers queue processing and anti-pattern detection for unindexed foreign keys.

How do I configure PostgreSQL connection limits and timeouts to prevent table bloat?

To prevent table bloat and manage resources, configure PostgreSQL connection limits and timeouts using the configuration template provided by this Skill. It also includes monitoring extensions to detect slow queries and anti-patterns early.