query-optimizer
Optimize SQL and Prisma queries using AI. Use when your queries are slow and you need performance help.
Why use this skill?
Improve database performance instantly. Detect N+1 issues, get index recommendations, and rewrite slow SQL or Prisma queries using our powerful AI-driven query optimizer.
Install via CLI (Recommended)
clawhub install openclaw/skills/skills/lxgicstudios/query-optimizerWhat This Skill Does
The Query Optimizer skill is a high-performance diagnostic tool designed to pinpoint and resolve inefficiencies in database interactions. Whether you are working with raw SQL or modern ORM syntax like Prisma, this skill acts as a virtual database administrator. It parses your code to identify expensive operations, such as full table scans, non-sargable predicates, or inefficient join patterns. By analyzing your queries, it provides actionable advice, including precise 'CREATE INDEX' statements to speed up lookups and refactoring suggestions to eliminate hidden performance bottlenecks. Its standout feature is its ability to detect 'N+1' query problems within ORM code, which is a common but often overlooked culprit behind application latency. The skill essentially translates abstract performance issues into concrete, testable code fixes.
Installation
Installation is handled through the OpenClaw ecosystem. You can add this skill to your workspace by running:
clawhub install openclaw/skills/skills/lxgicstudios/query-optimizer
Ensure you have Node.js 18+ installed on your system. To enable the underlying AI-powered analysis, you must set your environment variable: export OPENAI_API_KEY=sk-.... No local database connection or complex setup is required, as the tool operates by analyzing the text of your query files or pasted SQL strings.
Use Cases
This skill is perfect for scenarios where you suspect database performance is hindering your application. Typical use cases include debugging slow API endpoints identified by your APM, refactoring legacy codebases with inefficient data access patterns, or ensuring your Prisma models are supported by optimized indices before shipping to production. It is also an excellent educational tool for junior developers learning how to write performant database queries.
Example Prompts
- "Analyze this Prisma query to see why it takes 3 seconds to return: [code snippet]"
- "I am getting a lot of slow query logs for this SQL command. Can you suggest an index? SELECT * FROM users WHERE status = 'active' AND last_login < '2023-01-01'"
- "Check the following file for potential N+1 issues and suggest a more efficient way to fetch these records using Prisma: src/repositories/orderRepository.ts"
Tips & Limitations
To get the best results, always provide the database schema or table structure along with your query. The optimizer works best when it understands the existing indexing strategy and table relationships. Remember that while the tool provides excellent suggestions, you should always validate these changes using EXPLAIN ANALYZE on your specific database engine. The tool is designed for optimization, not data migration or schema design, so verify all suggested CREATE statements in a staging environment before running them against production data. Finally, avoid premature optimization; focus on queries that are actually impacting user experience or system resources.
Metadata
Not sure this is the right skill?
Describe what you want to build — we'll match you to the best skill from 16,000+ options.
Find the right skillPaste this into your clawhub.json to enable this plugin.
{
"plugins": {
"official-lxgicstudios-query-optimizer": {
"enabled": true,
"auto_update": true
}
}
}Tags(AI)
Flags: file-read, external-api
Related Skills
script-gen
Generate package.json scripts with AI. Use when setting up npm scripts.
email-template-gen
Generate responsive email templates. Use when building transactional emails.
branch-namer
Generate descriptive git branch names from plain English. Use when you need a branch name that follows conventions.
cloudflare-gen
Generate Cloudflare Workers configuration and code. Use when building on the edge.
adr-writer
Generate Architecture Decision Records with AI. Use when documenting technical decisions.