Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
aj-geddes avatar

Database Indexing Strategy

  • 437 installs
  • 305 repo stars
  • Updated March 4, 2026
  • aj-geddes/useful-ai-prompts

database-indexing-strategy is an agent skill that helps developers design PostgreSQL and MySQL indexing strategies by analyzing access patterns and balancing read speed with write overhead.

About

database-indexing-strategy is an agent skill from aj-geddes/useful-ai-prompts for planning indexes on PostgreSQL and MySQL workloads. It covers B-tree, Hash, GiST, and BRIN index types, plus composite, partial, filtered, and expression indexes with concrete CREATE INDEX examples. Three reference guides ship in the skill's references/ directory for PostgreSQL types, MySQL types, and single- versus multi-column patterns. Use it when EXPLAIN shows sequential scans, lock contention rises on hot tables, or new queries need index coverage without bloating storage. The skill emphasizes maintenance and monitoring alongside creation so indexes stay aligned with real access patterns.

  • Maps queries to composite and covering indexes
  • Weighs read gains against write amplification
  • Covers partial, functional, and unique indexes
  • Plans migration and backfill sequencing
  • Ties indexes to EXPLAIN plans and SLOs

Database Indexing Strategy by the numbers

  • 437 all-time installs (skills.sh)
  • Ranked #134 of 911 Databases skills by installs in the Skillselion catalog
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill database-indexing-strategy

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs437
repo stars305
Last updatedMarch 4, 2026
Repositoryaj-geddes/useful-ai-prompts

How do you design database indexes for slow queries?

Design indexing strategies for slow queries by analyzing access patterns, choosing composite and partial indexes, and balancing read speed with write overhead and storage cost.

Who is it for?

Backend developers tuning PostgreSQL or MySQL schemas where EXPLAIN plans show sequential scans or write-heavy tables need selective indexes.

Skip if: NoSQL-only stores or teams that only need connection pooling without query-level index design.

When should I use this skill?

A developer reports slow SQL, asks about composite or partial indexes, or needs GiST, BRIN, or B-tree selection guidance.

What you get

CREATE INDEX statements, composite and partial index plans, and index-type selection notes for PostgreSQL or MySQL

  • CREATE INDEX statements
  • Index-type recommendation
  • Maintenance checklist

By the numbers

  • Includes 3 reference guides in the references/ directory for PostgreSQL types, MySQL types, and column-index patterns
  • Documents 4 index families: B-tree, Hash, GiST, and BRIN

Files

SKILL.mdMarkdownGitHub ↗

Database Indexing Strategy

Table of Contents

Overview

Design comprehensive indexing strategies to improve query performance, reduce lock contention, and maintain data integrity. Covers index types, design patterns, and maintenance procedures.

When to Use

  • Index creation and planning
  • Query performance optimization through indexing
  • Index type selection (B-tree, Hash, GiST, BRIN)
  • Composite and partial index design
  • Index maintenance and monitoring
  • Storage optimization with indexes
  • Full-text search index design

Quick Start

B-tree Indexes (Default):

-- Standard equality and range queries
CREATE INDEX idx_users_email ON users(email);
CREATE INDEX idx_orders_created_at ON orders(created_at DESC);

-- Composite indexes for multi-column queries
CREATE INDEX idx_orders_user_status
ON orders(user_id, status)
WHERE cancelled_at IS NULL;

Reference Guides

Detailed implementations in the references/ directory:

GuideContents
PostgreSQL Index TypesPostgreSQL Index Types
MySQL Index TypesMySQL Index Types
Single Column IndexesSingle Column Indexes, Composite Indexes, Partial/Filtered Indexes, Expression Indexes

Best Practices

✅ DO

  • Follow established patterns and conventions
  • Write clean, maintainable code
  • Add appropriate documentation
  • Test thoroughly before deploying

❌ DON'T

  • Skip testing or validation
  • Ignore error handling
  • Hard-code configuration values

Related skills

How it compares

Pick database-indexing-strategy over generic SQL skills when the task is index-type selection and CREATE INDEX design rather than general query rewriting.

FAQ

Which databases does database-indexing-strategy support?

database-indexing-strategy targets PostgreSQL and MySQL. It documents B-tree, Hash, GiST, and BRIN types plus composite, partial, filtered, and expression indexes with SQL examples and three reference guides.

When should you add a partial index?

database-indexing-strategy recommends partial indexes when queries consistently filter on a subset of rows—e.g., active orders with WHERE cancelled_at IS NULL—so the index stays smaller and cheaper to maintain than a full-table index.

Databasesdatabasesanalytics

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.