Back to Developers
Developerssql-tuningdatabase-performancequery-optimization
SQL Query Optimization Architect
Analyzes slow-running SQL queries, pinpoints performance bottlenecks, and rewrites them for lightning-fast execution.
Use Case
Use this prompt when a database query is running slowly, causing application lag, or experiencing execution timeouts in production.
AI Prompt
Act as an expert Database Administrator. Analyze the following SQL query for potential performance bottlenecks: [insert SQL query]. Explain what database execution issues might occur, identify indexing strategies that would optimize it, and rewrite the query to be highly efficient for a [insert database engine, e.g., PostgreSQL, MySQL] database.
How to Use
- 1Copy your slow SQL query and specify your database engine.
- 2Submit the prompt to identify missing indexes, redundant joins, or poor search criteria.
- 3Implement the suggested database indexes and apply the rewritten, optimized SQL query to your codebase.
Example Output
Analysis of the query shows a bottleneck caused by a nested subquery and an unindexed string comparison in the WHERE clause. To fix this, we can rewrite the query using an inner join instead of the subquery, which allows the query optimizer to plan a more efficient search path. We also recommend creating a composite index on the user status and updated timestamp fields to prevent a full table scan.
Related Prompts
View AllHigh-Performance Database Query Optimizer
Identifies bottlenecks, suggests indexes, and rewrites slow-running SQL queries for optimal performance.
sqldatabasequery-optimization
View Prompt
REST API Schema to SDK Generator
Generates a fully typed, clean, and robust SDK client wrapper from a raw JSON or OpenAPI schema.
apisdk-generatorboilerplate
View Prompt
Production-Ready Kubernetes Manifest and Dockerfile Architect
Generates optimized, multi-stage Dockerfiles and secure, production-grade Kubernetes deployment manifests.
dockerkubernetesdevops
View Prompt