database-optimization

Profile slow queries and optimize indexes in PostgreSQL, Prisma, and Supabase.

8|Updated Feb 8, 2026
One-click install
npx skills add https://github.com/kensaurus/cursor-kenji --skill database-optimization-kensaurus
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-optimization
Source: https://github.com/kensaurus/cursor-kenji/tree/main/skills/database-optimization
Command: npx skills add https://github.com/kensaurus/cursor-kenji --skill database-optimization-kensaurus

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill provides a structured, repeatable approach to identifying and fixing database performance issues across PostgreSQL, Prisma, and Supabase. It guides you through validating the current state, applying targeted index improvements, and tuning queries to reduce latency and resource usage.

Core Features & Use Cases

  • CRITICAL: Check Existing First: Verify current indexes, migrations, and advisor hints before making changes.
  • Performance Investigation: Identify slow queries and analyze their execution plans to determine bottlenecks.
  • N+1 Query Fix: Replace iterative fetches with eager loading to minimize database round-trips.
  • Index Optimization: Recommend and implement single, composite, partial, and specialized indexes to accelerate filters and joins.
  • Query Analysis & Best Practices: Provide patterns for selecting fields, paginating results, and batching operations.
  • Schema Design Guidance: Balance normalization and denormalization to optimize read/write performance.
  • Supabase-Specific Tips: Optimize RLS and edge-function use for scalable data access.
  • Operational Checklist: Ensure monitoring, explain analyze, and safe deployment practices.

Quick Start

Begin by profiling slow queries, running explain analyze, and iteratively applying targeted indexes and query optimizations until performance meets the desired targets.

Frequently Asked Questions about database-optimization

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

FAQPage Schema
How do I fix slow PostgreSQL queries causing page load timeouts?

Fix slow PostgreSQL queries by profiling execution plans with explain analyze, validating existing indexes, and applying targeted composite or partial indexes to reduce latency and resolve page load timeouts.

What is the best way to resolve N+1 query problems in Prisma?

Resolve Prisma N+1 query problems by replacing iterative fetches with eager loading patterns, minimizing database round-trips, and selecting specific fields to optimize overall query performance.

When do I need to add composite or partial indexes in Supabase?

Add composite or partial indexes in Supabase when profiling reveals slow filters or joins, ensuring you also optimize RLS policies and edge-functions to maintain scalable data access.

How to analyze a database execution plan to identify performance bottlenecks?

Analyze database execution plans by running explain analyze on slow queries to identify bottlenecks, validating current migrations, and iteratively tuning schemas until performance targets are met.

Does database index optimization work across development, staging, and production environments?

Database index optimization works across development, staging, and production by validating migrations, applying safe deployment practices, and ensuring robust indexing for measurable performance gains.