- Home
- Skills
- Data & Databases
- Freebies — Index Creation Helper
Works with the AI Agents you already use
Freebies — Index Creation Helper
Generate optimal PostgreSQL/SQL index strategies and DDL for slow queries and high-volume workloads.
Free
Freebies — Index Creation Helper
Example session with this skill installed
Analyze this query: SELECT email FROM users WHERE organization_id = 500 AND status = 'active' ORDER BY created_at DESC; Table has 5M rows. Organization_id is an integer.
- Read your context and instructions
- Compiled the freebies
I have analyzed the query patterns and data volume for your users table. To optimize the filtering on organization_id and status while satisfying the ORDER BY clause, a composite B-Tree index is recommended.
Database Indexing Strategy
| Property | Recommendation | Justification |
|---|---|---|
| Index Type | B-Tree (Composite) | Optimal for equality filters and range-based sorting. |
| Column Order | organization_id, status, created_at | Follows Leftmost Prefix rule: Equality columns first, sort column last. |
| Strategy | Partial Index | status = 'active' covers the specific query filter to reduce storage footprint. |
Recommended DDL Statement
CREATE INDEX idx_users_org_active_created
ON users (organization_id, created_at DESC)
WHERE status = 'active';
Technical Justification
Leftmost Prefixing: By placing organization_id first, the database can immediately narrow the scan to the specific organization before sorting.
2.
Partial Optimization: Since the query specifically filters for 'active' users, creating a partial index excludes the millions of inactive or archived users, keeping the index small and fast to update.
3.
Sort Satisfaction: Including created_at in the index allows the database to retrieve rows in the correct order without an expensive in-memory sort operation.
Next steps
- Run
EXPLAIN ANALYZEwith the existing query to establish a performance baseline. - Apply the
CREATE INDEXstatement in a test or staging environment. - Verify the query plan changes from a
Sequential Scanto anIndex Scan.
Connects securely to your tools. The creator never sees your data.
About this skill
Slow database queries drag down application performance and increase infrastructure costs. This skill analyzes your SQL workloads to determine the exact indexing strategy required to lower latency.
What it does
- Analyze clauses scans WHERE, JOIN, and ORDER BY patterns to identify bottleneck columns.
- Select index types chooses between B-Tree, GIN, and GiST based on data types like JSONB, arrays, or geometric data.
- Structure composite indexes applies the Leftmost Prefix rule to optimize multi-column lookups.
- Design partial indexes creates targeted indexes for specific data subsets to minimize storage overhead and write amplification.
How it works
- Provide the SQL query and the table schema to the agent.
- The agent identifies which columns are used for filtering, joining, and sorting.
- It selects the most efficient index structure for the specific database engine.
- You receive a precise CREATE INDEX DDL statement along with a technical justification.
Frameworks & tools
This skill works with any SQL-based environment, with specialized support for B-Tree, GIN, and GiST indexes commonly found in PostgreSQL, MySQL, and similar relational databases.
Why this beats prompting it yourself
Generic prompts often miss the nuances of the Leftmost Prefix rule or fail to recommend GIN indexes for JSONB fields. This skill follows a deterministic workflow to ensure composite index column order and partial filter logic are architecturally sound.
Use cases
- Fix slow endpoints by indexing columns used in complex JOIN and WHERE clauses.
- Optimize JSONB performance with GIN index recommendations for document-style data.
- Reduce index size by implementing partial indexes on high-cardinality status columns.
- Improve sort performance by aligning composite index structures with ORDER BY requirements.
Known limitations
Does not perform live database execution or automated migration application. All analysis is restricted to the local workspace.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Data & Databases.
Restricted to static analysis within the local project workspace. Does not execute DDL directly on live databases or install global system packages.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Free to use
No account required to browse
Trust & safety
Security scan
Security scan passed 2 days ago
- Free with an Agensi account
- Software
- Zero global installationorelevated privileges required.
File System Read/Write (strictly scoped to current project workspace `./`).
Permissions
Target Use Cases: - Recommend the best index for this SQL query. - Design a composite index following leftmost prefix rule. - Create a partial index in PostgreSQL for active users.