Skip to main content
skill CX Codex

database-indexing-strategy — Claude Code skill: Postgres and MySQL

A skill for planning indexes: picks the type, builds composite and partial ones, covers maintenance. Useful when queries slow down.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add aj-geddes/useful-ai-prompts --skill database-indexing-strategy -a claude-code
Open on GitHub

What database-indexing-strategy does

The skill covers index planning for PostgreSQL and MySQL. It walks through type selection (B-tree, Hash, GiST, BRIN), composite and partial indexes, expression indexes, full-text search, plus maintenance and monitoring. The quick start shows the common cases: an index on email, one on created_at DESC, and a composite on user_id and status with WHERE cancelled_at IS NULL.

The layout is plain: a SKILL.md file and a references/ directory with three guides — PostgreSQL index types, MySQL index types, and single-column, composite, partial and expression indexes. Your agent opens the right file when you ask about a specific query or table.

One limit worth knowing: this is about indexes, not the whole schema. If the query itself is slow because of joins or the planner, the skill won't fix that. And before adding an index to production, check how it lands on writes — that's a reason to run the scenario on a copy first.

What it helps with

  • pick an index type for a date-range query
  • replace three single-column indexes with one composite
  • add a partial index for active orders
  • set up full-text search in PostgreSQL
  • plan index maintenance and monitoring

Example prompts for the agent

  • look at this query plan and suggest an index for PostgreSQL
  • I need a composite index on user_id and status, only for non-cancelled orders
  • which MySQL indexes would speed up this SELECT, and how do they differ from B-tree

How to install database-indexing-strategy

1Skills CLI (Vercel)

npx skills add aj-geddes/useful-ai-prompts --skill database-indexing-strategy -a claude-code

2Manually: put the files in place

~/.claude/skills/database-indexing-strategy/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/database-indexing-strategy/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about database-indexing-strategy

How do I install database-indexing-strategy in Claude?

Run npx skills add aj-geddes/useful-ai-prompts --skill database-indexing-strategy -a claude-code. The skill lands in ~/.claude/skills/database-indexing-strategy/SKILL.md.

What does database-indexing-strategy do?

It helps design indexes: picks the type, suggests composite and partial options, and covers maintenance and monitoring. It targets PostgreSQL and MySQL.

Which databases are supported?

PostgreSQL and MySQL. The references/ directory holds separate index-type guides for each.

Source text

SKILL.md · MIT
---
name: database-indexing-strategy
description: >
  Design and implement database indexing strategies. Use when creating indexes,
  choosing index types, or optimizing index performance in PostgreSQL and MySQL.
---

# Database Indexing Strategy

## Table of Contents

- [Overview](#overview)
- [When to Use](#when-to-use)
- [Quick Start](#quick-start)
- [Reference Guides](#reference-guides)
- [Best Practices](#best-practices)

## 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):**

```sql
-- 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:

| Guide | Contents |
|---|---|
| [PostgreSQL Index Types](references/postgresql-index-types.md) | PostgreSQL Index Types |
| [MySQL Index Types](references/mysql-index-types.md) | MySQL Index Types |
| [Single Column Indexes](references/single-column-indexes.md) | Single 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

© aj-geddes · MIT · aj-geddes/useful-ai-prompts

Similar skills

All skills for Data and databases →

From the same set118

code-documentation A skill that makes the agent write documentation inside your code: JSDoc, Python docstrings, JavaDoc, inline comments and API notes. Useful when functions and classes need describing, not rewriting. CX Codex +1 492installs reactive-programming A skill for reactive streams in RxJS: observables, operators, backpressure. Useful when a project leans on async data and events. CX Codex +1 491installs api-pagination A skill that tells the agent how to page through big collections: offset/limit, cursors, keyset. Useful when a user list or search result set outgrows one response. CX Codex +1 489installs nosql-database-design Guides the agent through NoSQL schema work: MongoDB collections, DynamoDB tables, embedding vs referencing, indexes. Useful before the schema hardens in code. CX Codex +1 486installs uptime-monitoring A skill that walks your coding agent through uptime checks, a public status page and incident tracking. Useful when you need to know which dependency actually broke. CX Codex +1 484installs api-response-optimization A coding-agent skill that trims payloads, adds caching and compression, and gives you a checklist for slow API endpoints. CX Codex +1 484installs background-job-processing A skill for wiring up background job processing: task queues, workers, scheduling and retries. Useful when emails, reports or large exports should not block the request path. CX Codex +1 483installs accessibility-compliance This skill guides accessibility work for WCAG 2.1/2.2, keyboard navigation, screen readers and a11y checks in web interfaces. CX Codex +1 482installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor