agency-database-optimizer

Optimizes database schemas, queries, and indexes for PostgreSQL, MySQL, Supabase, and PlanetScale.

Updated Jul 27, 2026
One-click install
npx skills add https://github.com/imMamdouhaboammar/Mimera --skill agency-database-optimizer-immamdouhaboammar
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: agency-database-optimizer
Source: https://github.com/imMamdouhaboammar/Mimera/tree/main/.agents/skills/engineering-database-optimizer
Command: npx skills add https://github.com/imMamdouhaboammar/Mimera --skill agency-database-optimizer-immamdouhaboammar

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Slow queries, missing indexes, N+1 patterns, and risky migrations degrade application performance and cause production incidents. This Skill provides expert database guidance to design scalable schemas, diagnose slow queries with EXPLAIN ANALYZE, and ship safe, reversible migrations. ## Core Features & Use Cases - Schema Design & Indexing: Creates normalized schemas with indexed foreign keys, partial indexes, and composite indexes matched to query patterns. - Query Optimization: Interprets EXPLAIN ANALYZE output, eliminates N+1 queries with JOINs and JSON aggregation, and rewrites inefficient SQL. - Safe Migrations & Pooling: Produces reversible zero-lock migrations using CONCURRENTLY and configures connection pooling for Supabase and serverless environments. - Use Case: Your API endpoint slows down as data grows. Ask the Skill to review the query, and it identifies a sequential scan, adds a composite index, and rewrites the N+1 loop into a single aggregated query. ## Quick Start Ask the database optimizer to review your slow PostgreSQL query and suggest indexes and an optimized rewrite.

Frequently Asked Questions about agency-database-optimizer

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

FAQPage Schema
How do I fix a slow PostgreSQL query?▼

Run EXPLAIN ANALYZE on the query to inspect the execution plan. Look for sequential scans on large tables, mismatched row estimates, and missing indexes, then add a targeted index or rewrite the query to use joins instead of repeated lookups.

How to prevent N+1 queries in application code?▼

Replace per-row queries inside loops with a single query using JOINs and JSON aggregation, or use batch loading. In PostgreSQL, json_agg with a LEFT JOIN fetches parent records and their children in one round trip.

Which index type should I use in PostgreSQL?▼

B-tree indexes cover most equality and range queries. Use GIN for JSONB or array containment, GiST for geometric or full-text data, and partial indexes when queries consistently filter on a condition like status = 'published'.

Does adding an index lock the table in production?▼

A standard CREATE INDEX locks writes on the table. Use CREATE INDEX CONCURRENTLY to build the index without blocking reads and writes, noting it cannot run inside a transaction block.

Can I use connection pooling with Supabase serverless functions?▼

Yes. Route connections through the Supabase transaction pooler by switching the database port from 5432 to 6543, and disable session persistence in the client since server-side code does not need auth session storage.