ecc-postgres-patterns

Provides PostgreSQL patterns for indexing, schema design, query optimization, and row-level security.

Updated May 26, 2026
One-click install
npx skills add https://github.com/avel123111/triplanio --skill ecc-postgres-patterns-avel123111
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ecc-postgres-patterns
Source: https://github.com/avel123111/triplanio/tree/main/.claude/skills/ecc-postgres-patterns
Command: npx skills add https://github.com/avel123111/triplanio --skill ecc-postgres-patterns-avel123111

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing efficient PostgreSQL queries and schemas requires knowing which index types, data types, and query patterns to use, and mistakes like missing indexes or unoptimized RLS policies cause slow queries and security gaps. ## Core Features & Use Cases - Index Selection Guide: Cheat sheets mapping query patterns to B-tree, GIN, BRIN, composite, covering, and partial indexes. - Query Pattern Library: Ready-to-use SQL for UPSERT, cursor pagination, queue processing with SKIP LOCKED, and optimized RLS policies. - Anti-Pattern Detection: Diagnostic queries to find unindexed foreign keys, slow queries via pg_stat_statements, and table bloat. - Use Case: When writing a Supabase migration, consult this Skill to choose the correct data types (timestamptz, bigint, numeric), add the right indexes, and write RLS policies that avoid per-row function re-evaluation. ## Quick Start Ask the AI to review your SQL migration or query using the PostgreSQL patterns skill to check indexing, data types, and RLS policy correctness.

Frequently Asked Questions about ecc-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?

Match the index to the query pattern: B-tree for equality and range filters, composite indexes for multi-column conditions with equality columns first, GIN for jsonb containment and full-text search, and BRIN for time-series ranges.

How do I optimize Row Level Security policies in PostgreSQL?

Wrap auth function calls in a SELECT subquery, such as USING ((SELECT auth.uid()) = user_id), so the planner evaluates it once instead of per row. This significantly improves RLS query performance on large tables.

What data types should I use in PostgreSQL schema design?

Use bigint for IDs, text instead of varchar(255), timestamptz instead of timestamp, numeric(10,2) for money instead of float, and boolean for flags. These choices avoid precision loss and timezone bugs.

How do I find slow queries in PostgreSQL?

Enable the pg_stat_statements extension and query it for statements with mean_exec_time above your threshold, ordered by mean execution time. The skill provides a ready-made query for this plus checks for unindexed foreign keys and table bloat.

When should I use cursor pagination instead of OFFSET?

Use cursor pagination (WHERE id > last_id ORDER BY id LIMIT n) for large datasets because it runs in O(1) time, while OFFSET scans and discards rows, making it O(n) and progressively slower on deep pages.