Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Use when optimizing PostgreSQL queries, configuring replication, or implementing advanced database features. Invoke for EXPLAIN analysis, JSONB operations, extension usage, VACUUM tuning, performance monitoring.
.claude/skills/jeffallan-postgres-pro/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 50% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 39% | 0% |
| case-20 | ✓→✓ | = Same ✓ | 42% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 35% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 33% | 0% |
Senior PostgreSQL expert with deep expertise in database administration, performance optimization, and advanced PostgreSQL features.
EXPLAIN (ANALYZE, BUFFERS) to identify bottlenecksEXPLAIN before deployingANALYZE to refresh statisticspg_stat views; verify improvements after each changesql-- Step 1: Identify slow queries SELECT query, mean_exec_time, calls FROM pg_stat_statements ORDER BY mean_exec_time DESC LIMIT 10; -- Step 2: Analyze a specific slow query EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT) SELECT * FROM orders WHERE customer_id = 42 AND status = 'pending'; -- Look for: Seq Scan (bad on large tables), high Buffers hit, nested loops on large sets -- Step 3: Create a targeted index CREATE INDEX CONCURRENTLY idx_orders_customer_status ON orders (customer_id, status) WHERE status = 'pending'; -- partial index reduces size -- Step 4: Verify the index is used EXPLAIN (ANALYZE, BUFFERS) SELECT * FROM orders WHERE customer_id = 42 AND status = 'pending'; -- Confirm: Index Scan on idx_orders_customer_status, lower actual time -- Step 5: Update statistics if needed after bulk changes ANALYZE orders;
Load detailed guidance based on context:
| Topic | Reference | Load When | |-------|-----------|-----------| | Performance | references/performance.md | EXPLAIN ANALYZE, indexes, statistics, query tuning | | JSONB | references/jsonb.md | JSONB operators, indexing, GIN indexes, containment | | Extensions | references/extensions.md | PostGIS, pg_trgm, pgvector, uuid-ossp, pg_stat_statements | | Replication | references/replication.md | Streaming replication, logical replication, failover | | Maintenance | references/maintenance.md | VACUUM, ANALYZE, pg_stat views, monitoring, bloat |
sql-- Create GIN index for containment queries CREATE INDEX idx_events_payload ON events USING GIN (payload); -- Efficient JSONB containment query (uses GIN index) SELECT * FROM events WHERE payload @> '{"type": "login", "success": true}'; -- Extract nested value SELECT payload->>'user_id', payload->'meta'->>'ip' FROM events WHERE payload @> '{"type": "login"}';
sql-- Check tables with high dead tuple counts SELECT relname, n_dead_tup, n_live_tup, round(n_dead_tup::numeric / NULLIF(n_live_tup + n_dead_tup, 0) * 100, 2) AS dead_pct, last_autovacuum FROM pg_stat_user_tables ORDER BY n_dead_tup DESC LIMIT 20; -- Manually vacuum a high-churn table and verify VACUUM (ANALYZE, VERBOSE) orders;
sql-- On primary: check standby lag SELECT client_addr, state, sent_lsn, write_lsn, flush_lsn, replay_lsn, (sent_lsn - replay_lsn) AS replication_lag_bytes FROM pg_stat_replication;
EXPLAIN (ANALYZE, BUFFERS) for query optimizationEXPLAIN before and after creationCREATE INDEX CONCURRENTLY to avoid table locks in productionANALYZE after bulk data changes to refresh statisticsautovacuum_vacuum_scale_factor for high-churn tablespg_stat_replicationuuid type for UUIDs, not textSELECT * in production queriesWhen implementing PostgreSQL solutions, provide:
EXPLAIN (ANALYZE, BUFFERS) output and interpretationPostgreSQL 12-16, EXPLAIN ANALYZE, B-tree/GIN/GiST/BRIN indexes, JSONB operators, streaming replication, logical replication, VACUUM/ANALYZE, pg_stat views, PostGIS, pgvector, pg_trgm, WAL archiving, PITR
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-20 | pass→pass | 14,108 | 11,597 | -18% | 1 | 1 | 0% | 2,429 | 3,441 | +42% | 0 | 0 | — |
case-01 | fail→pass | 15,502 | 13,194 | -15% | 1 | 1 | 0% | 2,858 | 4,299 | +50% | 0 | 0 | — |
case-02 | pass→pass | 11,951 | 8,308 | -30% | 1 | 1 | 0% | 2,167 | 2,926 | +35% | 0 | 0 | — |
case-03 | pass→pass | 14,642 | 12,669 | -13% | 1 | 1 | 0% | 2,588 | 3,448 | +33% | 0 | 0 | — |
case-04 | pass→pass | 5,629 | 7,464 | +33% | 1 | 1 | 0% | 1,020 | 2,782 | +173% | 0 | 0 | — |
case-05 | pass→pass | 5,871 | 4,371 | -26% | 1 | 1 | 0% | 1,003 | 2,072 | +107% | 0 | 0 | — |
case-06 | pass→pass | 15,770 | 12,472 | -21% | 1 | 1 | 0% | 2,701 | 3,858 | +43% | 0 | 0 | — |
case-07 | pass→pass | 3,577 | 4,772 | +33% | 1 | 1 | 0% | 596 | 2,292 | +285% | 0 | 0 | — |
case-08 | fail→pass | 10,071 | 6,823 | -32% | 1 | 1 | 0% | 1,956 | 2,713 | +39% | 0 | 0 | — |
case-09 | pass→pass | 17,841 | 11,456 | -36% | 1 | 1 | 0% | 2,917 | 3,380 | +16% | 0 | 0 | — |
case-10 | pass→pass | 3,691 | 4,664 | +26% | 1 | 1 | 0% | 765 | 2,326 | +204% | 0 | 0 | — |
case-11 | pass→pass | 11,628 | 8,260 | -29% | 1 | 1 | 0% | 2,286 | 2,905 | +27% | 0 | 0 | — |
case-12 | pass→pass | 6,832 | 7,052 | +3% | 1 | 1 | 0% | 1,555 | 2,719 | +75% | 0 | 0 | — |
case-13 | pass→pass | 9,050 | 9,219 | +2% | 1 | 1 | 0% | 1,716 | 2,949 | +72% | 0 | 0 | — |
case-14 | pass→pass | 10,833 | 9,022 | -17% | 1 | 1 | 0% | 1,938 | 3,295 | +70% | 0 | 0 | — |
case-15 | pass→pass | 3,805 | 4,596 | +21% | 1 | 1 | 0% | 665 | 2,247 | +238% | 0 | 0 | — |
case-16 | pass→pass | 11,742 | 10,604 | -10% | 1 | 1 | 0% | 1,917 | 3,211 | +68% | 0 | 0 | — |
case-17 | pass→pass | 8,445 | 7,728 | -8% | 1 | 1 | 0% | 898 | 2,664 | +197% | 0 | 0 | — |
case-18 | pass→pass | 5,400 | 5,850 | +8% | 1 | 1 | 0% | 945 | 2,398 | +154% | 0 | 0 | — |
case-19 | pass→pass | 29,519 | 10,334 | -65% | 1 | 1 | 0% | 2,849 | 3,258 | +14% | 0 | 0 | — |
case-21 | pass→pass | 12,586 | 14,444 | +15% | 1 | 1 | 0% | 2,529 | 4,036 | +60% | 0 | 0 | — |
case-22 | pass→pass | 8,534 | 6,218 | -27% | 1 | 1 | 0% | 1,821 | 2,767 | +52% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +9 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.